From 6b85ae268c04e1ab1c9cfde4ca349fca9d7ce9b8 Mon Sep 17 00:00:00 2001 From: Andre Fachat Date: Wed, 30 Oct 2019 22:41:52 +0100 Subject: [PATCH] fixes issue#4 by ignoreing quoted strings when finding a preprocessor pattern to be replaced --- xa/src/xap.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/xa/src/xap.c b/xa/src/xap.c index e8ce798..a0d26bb 100644 --- a/xa/src/xap.c +++ b/xa/src/xap.c @@ -456,7 +456,25 @@ int pp_replace(char *to, char *ti, int a,int b) { while(t[0]!='\0') { - while(!isalpha(t[0]) && t[0]!='_') + /* find start of a potential token to be replaced */ + while(!isalpha(t[0]) && t[0]!='_') { + + /* escape strings quoted with " */ + if (t[0] == '\"') { + do { + t++; + ti++; + } while (t[0] && t[0]!='\"'); + } + + /* escape strings quoted with ' */ + if (t[0] == '\'') { + do { + t++; + ti++; + } while (t[0] && t[0]!='\''); + } + if(t[0]=='\0') break; /*return(E_OK);*/ else @@ -464,6 +482,7 @@ int pp_replace(char *to, char *ti, int a,int b) t++; ti++; } + } for(l=0;isalnum(t[l])||t[l]=='_';l++); ld=l;