* sim/ucsim/cmd.src/cmdutil.cc: NUL device is detected as CG_FILE type
[fw/sdcc] / src / pic / pcodepeep.c
index 6c6c47205bbd4629a713997338cb6da3dfcf2482..f041796a8831bfe6c60219dff63b8ee535e0a84e 100644 (file)
 #include "pcodeflow.h"
 #include "ralloc.h"
 
-#if defined(__BORLANDC__) || defined(_MSC_VER)
-#define STRCASECMP stricmp
-#else
-#define STRCASECMP strcasecmp
-#endif
-
 pCodeOp *popCopyGPR2Bit(pCodeOpReg *pc, int bitval);
 pCodeOp *popRegFromString(char *str, int size, int offset);
 
@@ -2100,9 +2094,10 @@ int pCodePeepMatchRule(pCode *pc)
                        /* 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);
                                
@@ -2111,13 +2106,14 @@ int pCodePeepMatchRule(pCode *pc)
                        /* Copy C code comments to new code. */
                        pc = pcprev->next;
                        if (pc) {
-                               for (; pcout!=pcin; pcout=pcout->next) {
+                               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;
                                        }
                                }