| 207 | } |
| 208 | |
| 209 | static char *dequote_value(const char *varname, char *varval) |
| 210 | { |
| 211 | const char **dqnam; |
| 212 | char *dqval = varval; |
| 213 | char *ptr; |
| 214 | int len; |
| 215 | int i; |
| 216 | |
| 217 | if (dqval) |
| 218 | { |
| 219 | /* Check if the variable name is in the dequoted list of strings */ |
| 220 | |
| 221 | for (dqnam = dequote_list; *dqnam; dqnam++) |
| 222 | { |
| 223 | if (strcmp(*dqnam, varname) == 0) |
| 224 | { |
| 225 | break; |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | /* Did we find the variable name in the list of configuration variables |
| 230 | * to be dequoted? |
| 231 | */ |
| 232 | |
| 233 | if (*dqnam) |
| 234 | { |
| 235 | /* Yes... Check if there is a trailing quote */ |
| 236 | |
| 237 | len = strlen(dqval); |
| 238 | if (dqval[len - 1] == '"') |
| 239 | { |
| 240 | /* Yes... replace it with a terminator */ |
| 241 | |
| 242 | dqval[len - 1] = '\0'; |
| 243 | len--; |
| 244 | } |
| 245 | |
| 246 | /* Is there a leading quote? */ |
| 247 | |
| 248 | if (dqval[0] == '"') |
| 249 | { |
| 250 | /* Yes.. skip over the leading quote */ |
| 251 | |
| 252 | dqval++; |
| 253 | len--; |
| 254 | } |
| 255 | |
| 256 | /* A special case is a quoted list of quoted strings. In that case |
| 257 | * we will need to remove the backspaces from the internally quoted |
| 258 | * strings. NOTE: this will not handle nested quoted quotes. |
| 259 | */ |
| 260 | |
| 261 | for (ptr = dqval; *ptr; ptr++) |
| 262 | { |
| 263 | /* Check for a quoted quote */ |
| 264 | |
| 265 | if (ptr[0] == '\\' && ptr[1] == '"') |
| 266 | { |
no test coverage detected