Mercurial > ~dholland > hg > tradcpp > index.cgi
comparison macro.c @ 177:6119608a9817
Finish joerg's halfassedly partial const changes.
(why only do half of it?)
author | David A. Holland |
---|---|
date | Fri, 12 Jun 2015 03:03:04 -0400 |
parents | ffdb0b73856f |
children | d359d9b86327 |
comparison
equal
deleted
inserted
replaced
176:a2f047301c15 | 177:6119608a9817 |
---|---|
675 }; | 675 }; |
676 | 676 |
677 static struct expstate mainstate; | 677 static struct expstate mainstate; |
678 | 678 |
679 static void doexpand(struct expstate *es, struct place *p, | 679 static void doexpand(struct expstate *es, struct place *p, |
680 char *buf, size_t len); | 680 const char *buf, size_t len); |
681 | 681 |
682 static | 682 static |
683 void | 683 void |
684 expstate_init(struct expstate *es, bool tobuf, bool honordefined) | 684 expstate_init(struct expstate *es, bool tobuf, bool honordefined) |
685 { | 685 { |
919 } | 919 } |
920 } | 920 } |
921 | 921 |
922 static | 922 static |
923 void | 923 void |
924 expand_got_ws(struct expstate *es, struct place *p, const char *buf, size_t len) | 924 expand_got_ws(struct expstate *es, struct place *p, |
925 const char *buf, size_t len) | |
925 { | 926 { |
926 switch (es->state) { | 927 switch (es->state) { |
927 case ES_NORMAL: | 928 case ES_NORMAL: |
928 expand_send(es, p, buf, len); | 929 expand_send(es, p, buf, len); |
929 break; | 930 break; |
941 } | 942 } |
942 } | 943 } |
943 | 944 |
944 static | 945 static |
945 void | 946 void |
946 expand_got_word(struct expstate *es, struct place *p, char *buf, size_t len) | 947 expand_got_word(struct expstate *es, struct place *p, |
948 const char *buf, size_t len) | |
947 { | 949 { |
948 struct macro *m; | 950 struct macro *m; |
949 | 951 |
950 switch (es->state) { | 952 switch (es->state) { |
951 case ES_NORMAL: | 953 case ES_NORMAL: |
990 } | 992 } |
991 } | 993 } |
992 | 994 |
993 static | 995 static |
994 void | 996 void |
995 expand_got_lparen(struct expstate *es, struct place *p, char *buf, size_t len) | 997 expand_got_lparen(struct expstate *es, struct place *p, |
998 const char *buf, size_t len) | |
996 { | 999 { |
997 switch (es->state) { | 1000 switch (es->state) { |
998 case ES_NORMAL: | 1001 case ES_NORMAL: |
999 expand_send(es, p, buf, len); | 1002 expand_send(es, p, buf, len); |
1000 break; | 1003 break; |
1013 } | 1016 } |
1014 } | 1017 } |
1015 | 1018 |
1016 static | 1019 static |
1017 void | 1020 void |
1018 expand_got_rparen(struct expstate *es, struct place *p, char *buf, size_t len) | 1021 expand_got_rparen(struct expstate *es, struct place *p, |
1022 const char *buf, size_t len) | |
1019 { | 1023 { |
1020 switch (es->state) { | 1024 switch (es->state) { |
1021 case ES_NORMAL: | 1025 case ES_NORMAL: |
1022 expand_send(es, p, buf, len); | 1026 expand_send(es, p, buf, len); |
1023 break; | 1027 break; |
1048 } | 1052 } |
1049 } | 1053 } |
1050 | 1054 |
1051 static | 1055 static |
1052 void | 1056 void |
1053 expand_got_comma(struct expstate *es, struct place *p, char *buf, size_t len) | 1057 expand_got_comma(struct expstate *es, struct place *p, |
1058 const char *buf, size_t len) | |
1054 { | 1059 { |
1055 switch (es->state) { | 1060 switch (es->state) { |
1056 case ES_NORMAL: | 1061 case ES_NORMAL: |
1057 expand_send(es, p, buf, len); | 1062 expand_send(es, p, buf, len); |
1058 break; | 1063 break; |
1076 } | 1081 } |
1077 } | 1082 } |
1078 | 1083 |
1079 static | 1084 static |
1080 void | 1085 void |
1081 expand_got_other(struct expstate *es, struct place *p, char *buf, size_t len) | 1086 expand_got_other(struct expstate *es, struct place *p, |
1087 const char *buf, size_t len) | |
1082 { | 1088 { |
1083 switch (es->state) { | 1089 switch (es->state) { |
1084 case ES_NORMAL: | 1090 case ES_NORMAL: |
1085 expand_send(es, p, buf, len); | 1091 expand_send(es, p, buf, len); |
1086 break; | 1092 break; |
1128 es->argparens = 0; | 1134 es->argparens = 0; |
1129 } | 1135 } |
1130 | 1136 |
1131 static | 1137 static |
1132 void | 1138 void |
1133 doexpand(struct expstate *es, struct place *p, char *buf, size_t len) | 1139 doexpand(struct expstate *es, struct place *p, const char *buf, size_t len) |
1134 { | 1140 { |
1135 char *s; | 1141 char *s; |
1136 size_t x; | 1142 size_t x; |
1137 bool inquote = false; | 1143 bool inquote = false; |
1138 char quote = '\0'; | 1144 char quote = '\0'; |
1217 len--; | 1223 len--; |
1218 } | 1224 } |
1219 } | 1225 } |
1220 | 1226 |
1221 char * | 1227 char * |
1222 macroexpand(struct place *p, char *buf, size_t len, bool honordefined) | 1228 macroexpand(struct place *p, const char *buf, size_t len, bool honordefined) |
1223 { | 1229 { |
1224 struct expstate es; | 1230 struct expstate es; |
1225 char *ret; | 1231 char *ret; |
1226 | 1232 |
1227 expstate_init(&es, true, honordefined); | 1233 expstate_init(&es, true, honordefined); |
1239 | 1245 |
1240 return ret; | 1246 return ret; |
1241 } | 1247 } |
1242 | 1248 |
1243 void | 1249 void |
1244 macro_sendline(struct place *p, char *buf, size_t len) | 1250 macro_sendline(struct place *p, const char *buf, size_t len) |
1245 { | 1251 { |
1246 doexpand(&mainstate, p, buf, len); | 1252 doexpand(&mainstate, p, buf, len); |
1247 switch (mainstate.state) { | 1253 switch (mainstate.state) { |
1248 case ES_NORMAL: | 1254 case ES_NORMAL: |
1249 /* | 1255 /* |