History

cpp: #pragma once support

Jacob Moody committed 3 years ago

Commit 7e3063e1 parent 0c5e15b3 files · +28 −1Browse files

Showing the changes to sys/src/cmd/cpp/cpp.c (1 of 3 files). Show all

Unified · Split

sys/src/cmd/cpp/cpp.c+12−1
@@ -85,6 +85,7 @@ control(Tokenrow *trp) · 84 unmodified lines
8585 {
8686 Nlist *np;
8787 Token *tp;
88+ Dir *d;
8889
8990 tp = trp->tp;
9091 if (tp->type!=NAME) {
@@ -148,7 +149,17 @@ control(Tokenrow *trp) · 57 unmodified lines
148149 break;
149150
150151 case KPRAGMA:
151− return;
152+ tp += 1;
153+ if (tp->type!=NAME || tp->len < 4 || memcmp(tp->t, "once", 4) != 0)
154+ return;
155+ if (nblocked >= NONCE)
156+ error(FATAL, "#pragma once list max length exceeded");
157+ d = dirfstat(cursource->fd);
158+ if (d == nil)
159+ error(FATAL, "Out of memory from dirfstat");
160+ incblocked[nblocked++] = d->qid;
161+ free(d);
162+ break;
152163
153164 case KIFDEF:
154165 case KIFNDEF:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t