comparison lwlink/lwlink.c @ 395:54499b799779

Q&D sanitization of symbols in map files and error messages in lwlink
author lost@l-w.ca
date Fri, 23 Jul 2010 16:40:51 -0600
parents 1c31e9005ff7
children
comparison
equal deleted inserted replaced
394:a2f52e97b454 395:54499b799779
103 *base = '='; 103 *base = '=';
104 104
105 scriptls = lw_realloc(scriptls, sizeof(char *) * (nscriptls + 1)); 105 scriptls = lw_realloc(scriptls, sizeof(char *) * (nscriptls + 1));
106 scriptls[nscriptls++] = t; 106 scriptls[nscriptls++] = t;
107 } 107 }
108
109 char *sanitize_symbol(char *symbol)
110 {
111 static char symbuf[2048];
112 char *sym = symbol;
113 char *tp = symbuf;
114
115 for (; *sym; sym++)
116 {
117 int c1 = *sym;
118 if (c1 == '\\')
119 {
120 *tp++ = '\\';
121 *tp++ = '\\';
122 continue;
123 }
124 if (c1 < 32 || c1 > 126)
125 {
126 int c;
127 *tp++ = '\\';
128 c = c1 >> 4;
129 c += 48;
130 if (c > 57)
131 c += 7;
132 *tp++ = c;
133 c = c1 & 15;
134 c += 48;
135 if (c > 57)
136 c += 7;
137 *tp++ = c;
138 continue;
139 }
140 *tp++ = c1;
141 }
142 *tp = 0;
143 return symbuf;
144 }