comparison lwasm/pragma.c @ 384:6ee9c67a0f8d

Add conditional for testing if a pragma is in effect An obvious addition that took someone else to notice... Thanks to Erik G <erik@6809.org> for the patch.
author William Astle <lost@l-w.ca>
date Mon, 13 Jul 2015 21:20:30 -0600
parents d791d47afc48
children 4fd16faa4d93
comparison
equal deleted inserted replaced
383:04e11f6faead 384:6ee9c67a0f8d
71 { "qrts", "noqrts", PRAGMA_QRTS }, 71 { "qrts", "noqrts", PRAGMA_QRTS },
72 { "m80ext", "nom80ext", PRAGMA_M80EXT }, 72 { "m80ext", "nom80ext", PRAGMA_M80EXT },
73 { 0, 0, 0 } 73 { 0, 0, 0 }
74 }; 74 };
75 75
76 int parse_pragma_helper(char *p)
77 {
78 int i;
79
80 for (i = 0; set_pragmas[i].setstr; i++)
81 {
82 if (!strcasecmp(p, set_pragmas[i].setstr))
83 {
84 return set_pragmas[i].flag;
85 return 1;
86 }
87 if (!strcasecmp(p, set_pragmas[i].resetstr))
88 {
89 return set_pragmas[i].flag | PRAGMA_CLEARBIT;
90 return 2;
91 }
92 }
93
94 return 0;
95 }
96
76 int parse_pragma_string(asmstate_t *as, char *str, int ignoreerr) 97 int parse_pragma_string(asmstate_t *as, char *str, int ignoreerr)
77 { 98 {
78 char *p; 99 char *p;
79 int i;
80 const char *np = str; 100 const char *np = str;
81 int pragmas = as -> pragmas; 101 int pragma;
82 102
83 while (np) 103 while (np)
84 { 104 {
85 p = lw_token(np, ',', &np); 105 p = lw_token(np, ',', &np);
86 debug_message(as, 200, "Setting pragma %s", p); 106 debug_message(as, 200, "Setting/resetting pragma %s", p);
87 for (i = 0; set_pragmas[i].setstr; i++) 107 pragma = parse_pragma_helper(p);
88 { 108 lw_free(p);
89 if (!strcasecmp(p, set_pragmas[i].setstr)) 109
90 { 110 if (pragma == 0 && !ignoreerr)
91 pragmas |= set_pragmas[i].flag;
92 goto out;
93 }
94 if (!strcasecmp(p, set_pragmas[i].resetstr))
95 {
96 pragmas &= ~(set_pragmas[i].flag);
97 goto out;
98 }
99 }
100 /* unrecognized pragma here */
101 if (!ignoreerr)
102 {
103 lw_free(p);
104 return 0; 111 return 0;
105 } 112
106 out: 113 if (pragma & PRAGMA_CLEARBIT)
107 lw_free(p); 114 as->pragmas &= ~pragma;
108 } 115 else
109 as -> pragmas = pragmas; 116 as->pragmas |= pragma;
117 }
110 return 1; 118 return 1;
111 } 119 }
112 120
113 PARSEFUNC(pseudo_parse_pragma) 121 PARSEFUNC(pseudo_parse_pragma)
114 { 122 {