Skip to content

Commit

Permalink
Merge pull request #308 from orbea/indent
Browse files Browse the repository at this point in the history
src/asar: fix -Wmisleading-indentation warnings
  • Loading branch information
p4plus2 authored Mar 1, 2024
2 parents 897c388 + b34c62c commit 5da0f5e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/asar/arch-spc700.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,15 @@ bool asblock_spc700(char** word, int numwords)
#define vc(left1, right1, str2) if (isvc(left1, right1, str2))
#define vv(left1, right1, left2, right2) if (isvv(left1, right1, left2, right2))
#define w0(opcode) do { write1((unsigned int)opcode); return true; } while(0)
#define w1(opcode, math) do { write1((unsigned int)opcode); unsigned int val=getnum_ck(math); \
if ((((val&0xFF00)&&(val&0x80000000)==0)||(((val&0xFF00)!=0xFF00)&&(val&0x80000000)))&&opLen!=1) asar_throw_warning(2, warning_id_spc700_assuming_8_bit); write1(val);return true; } while(0)
#define w1(opcode, math) \
do { \
write1((unsigned int)opcode); \
unsigned int val=getnum_ck(math); \
if ((((val&0xFF00) && (val&0x80000000) == 0) || (((val&0xFF00) != 0xFF00) && (val&0x80000000))) && opLen != 1) \
asar_throw_warning(2, warning_id_spc700_assuming_8_bit); \
write1(val);\
return true; \
} while(0)
#define w2(opcode, math) do { write1((unsigned int)opcode); write2(getnum_ck(math)); return true; } while(0)
#define wv(opcode1, opcode2, math) do { if ((opLen == 1) || (opLen == 0 && getlen(math)==1)) { write1((unsigned int)opcode1); write1(getnum_ck(math)); } \
else { write1((unsigned int)opcode2); write2(getnum_ck(math)); } return true; } while(0)
Expand Down
47 changes: 44 additions & 3 deletions src/asar/libstr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,50 @@ bool readfile(const char * fname, const char * basepath, char ** data, int * len
return true;
}

#define dequote(var, next, error) if (var=='"') do { next; while (var!='"' && var != '\0') { if (!var) error; next; } if (var == '\0') error; next; } while(0); else if (var=='\'') do { next; if (!var) error; /* ''' special case hack */ if (var=='\'') { next; if (var!='\'') error; next; } else { next; while (var!='\'' && var != '\0') { if (!var) error; next; } if (var == '\0') error; next; } } while(0)
#define skippar(var, next, error) dequote(var, next, error); else if (var=='(') { int par=1; next; while (par) { dequote(var, next, error); else { \
if (var=='(') par++; if (var==')') par--; if (!var) error; next; } } } else if (var==')') error
#define dequote(var, next, error) \
if (var=='"') \
do { \
next; \
while (var!='"' && var != '\0') { \
if (!var) error; \
next; \
} \
if (var == '\0') error; \
next; \
} while(0); \
else if (var=='\'') \
do { \
next; \
if (!var) error; /* ''' special case hack */ \
if (var=='\'') { \
next; \
if (var!='\'') error; \
next; \
} else { \
next; \
while (var!='\'' && var != '\0') { \
if (!var) error; \
next; \
} \
if (var == '\0') error; \
next; \
} \
} while(0)

#define skippar(var, next, error) \
dequote(var, next, error); \
else if (var=='(') { \
int par=1; next; \
while (par) { \
dequote(var, next, error); \
else { \
if (var=='(') par++; \
if (var==')') par--; \
if (!var) error; \
next; \
} \
} \
} else if (var==')') error

string& string::replace(const char * instr, const char * outstr, bool all)
{
Expand Down

0 comments on commit 5da0f5e

Please sign in to comment.