// just check first letter for now
- if(toupper(*pp->pct[0].tok.s) == 'F')
+ if(toupper((unsigned char)*pp->pct[0].tok.s) == 'F')
return 1;
} else if (pp->pct[0].tt == PCT_NUMBER) {
if(len == 1) {
// check C,Z
- if(toupper(*bit) == 'C')
+ if(toupper((unsigned char)*bit) == 'C')
return PCOP(popCopyGPR2Bit(&pc_status,PIC_C_BIT));
- if(toupper(*bit) == 'Z')
+ if(toupper((unsigned char)*bit) == 'Z')
return PCOP(popCopyGPR2Bit(&pc_status,PIC_Z_BIT));
}
// Check DC
- if(len ==2 && toupper(bit[0]) == 'D' && toupper(bit[1]) == 'C')
+ if(len ==2 && toupper((unsigned char)bit[0]) == 'D' && toupper((unsigned char)bit[1]) == 'C')
return PCOP(popCopyGPR2Bit(&pc_status,PIC_DC_BIT));
return NULL;
while(*ln) {
- if(isspace(*ln)) {
+ if(isspace((unsigned char)*ln)) {
// add a SPACE token and eat the extra spaces.
tokArr[tokIdx++].tt = PCT_SPACE;
- while (isspace (*ln))
+ while (isspace ((unsigned char)*ln))
ln++;
continue;
}
- if(isdigit(*ln)) {
+ if(isdigit((unsigned char)*ln)) {
tokArr[tokIdx].tt = PCT_NUMBER;
tokArr[tokIdx++].tok.n = strtol(ln, &ln, 0);
default:
- if(isalpha(*ln) || (*ln == '_') ) {
+ if(isalpha((unsigned char)*ln) || (*ln == '_') ) {
char buffer[50];
int i=0;
- while( (isalpha(*ln) || isdigit(*ln) || (*ln == '_')) && i<49)
+ while( (isalpha((unsigned char)*ln) || isdigit((unsigned char)*ln) || (*ln == '_')) && i<49)
buffer[i++] = *ln++;
ln--;
if(PCI(pc)->inCond & cond) {
if (contIfSkip) {
/* If previous instruction is a skip then continue search as condiction is not certain */
- pCode *pcp = findPrevInstruction(pc);
+ pCode *pcp = findPrevInstruction(pc->prev);
if (pcp && !isPCI_SKIP(pcp)) {
return 1;
}
if(PCI(pc)->outCond & cond) {
if (contIfSkip) {
/* If previous instruction is a skip then continue search as condiction is not certain */
- pCode *pcp = findPrevInstruction(pc);
+ pCode *pcp = findPrevInstruction(pc->prev);
if (pcp && !isPCI_SKIP(pcp)) {
return -1;
}
if(matched) {
pCode *pcprev;
- pCode *pcr;
+ pCode *pcr, *pcout;
/* We matched a rule! Now we have to go through and remove the
/* Unlink the original code */
+ pcout = pc;
pcprev = pc->prev;
pcprev->next = pcin;
if(pcin)
} else if (pcr->type == PC_COMMENT) {
pCodeInsertAfter(pc, newpCodeCharP( ((pCodeComment *)(pcr))->comment));
}
-
-
+
pc = pc->next;
#ifdef PCODE_DEBUG
DFPRINTF((stderr," NEW Code:"));
/* We have just replaced the inefficient code with the rule.
* Now, we need to re-add the C-source symbols if there are any */
pc = pcprev;
- while(pc_cline ) {
+ while(pc && pc_cline ) {
pc = findNextInstruction(pc->next);
+ if (!pc) break;
PCI(pc)->cline = pc_cline;
pc_cline = PCCS(pc_cline->pc.next);
}
+ /* Copy C code comments to new code. */
+ pc = pcprev->next;
+ if (pc) {
+ for (; pc && pcout!=pcin; pcout=pcout->next) {
+ if (pcout->type==PC_OPCODE && PCI(pcout)->cline) {
+ while (pc->type!=PC_OPCODE || PCI(pc)->cline) {
+ pc = pc->next;
+ if (!pc)
+ break;
+ }
+ if (!pc) break;
+ PCI(pc)->cline = PCI(pcout)->cline;
+ }
+ }
+ }
+
return 1;
- }
+ }
next_rule:
- peeprules = peeprules->next;
- }
- DFPRINTF((stderr," no rule matched\n"));
+ peeprules = peeprules->next;
+ }
+ DFPRINTF((stderr," no rule matched\n"));
- return 0;
+ return 0;
}