From c6b604ac1add4ea0416c7bf65f6dec3ca5b68c7b Mon Sep 17 00:00:00 2001
From: Martin Nilsson <mani@lysator.liu.se>
Date: Sat, 3 May 2008 17:29:26 +0200
Subject: [PATCH] Put all illegal size shift fatals behind ifdef PIKE_DEBUG.

Rev: src/builtin.cmod:1.199
Rev: src/builtin_functions.c:1.660
Rev: src/cpp.c:1.169
Rev: src/encode.c:1.265
Rev: src/iterators.cmod:1.66
Rev: src/operators.c:1.231
Rev: src/preprocessor.h:1.93
Rev: src/program.c:1.683
Rev: src/sscanf.c:1.172
Rev: src/stralloc.c:1.217
---
 src/builtin.cmod        |  4 +++-
 src/builtin_functions.c | 22 ++++++++++++++++------
 src/cpp.c               |  6 +++++-
 src/encode.c            |  4 +++-
 src/iterators.cmod      | 16 ++++++++++++++--
 src/operators.c         |  4 +++-
 src/preprocessor.h      |  6 +++++-
 src/program.c           |  4 +++-
 src/sscanf.c            |  4 +++-
 src/stralloc.c          | 22 +++++++++++++++++++++-
 10 files changed, 76 insertions(+), 16 deletions(-)

diff --git a/src/builtin.cmod b/src/builtin.cmod
index a86881e7f0..2c450c6127 100644
--- a/src/builtin.cmod
+++ b/src/builtin.cmod
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: builtin.cmod,v 1.198 2008/04/23 07:37:03 mast Exp $
+|| $Id: builtin.cmod,v 1.199 2008/05/03 15:29:24 nilsson Exp $
 */
 
 #include "global.h"
@@ -2491,8 +2491,10 @@ PIKECLASS bootstring
 	    s[p] = DO_NOT_WARN ((p_wchar2) n);
 	  }
 	  break;
+#ifdef PIKE_DEBUG
 	default:
 	  Pike_fatal("Illegal shift size!\n");
+#endif
 	}
       i++;
     }
diff --git a/src/builtin_functions.c b/src/builtin_functions.c
index dfe1cb0315..02b4b3ad71 100644
--- a/src/builtin_functions.c
+++ b/src/builtin_functions.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: builtin_functions.c,v 1.659 2008/05/02 04:15:09 mast Exp $
+|| $Id: builtin_functions.c,v 1.660 2008/05/03 15:29:24 nilsson Exp $
 */
 
 #include "global.h"
@@ -336,9 +336,11 @@ PMOD_EXPORT void f_hash(INT32 args)
   case 2:
     i = simple_hashmem2(STR2(s), s->len, 100);
     break;
+#ifdef PIKE_DEBUG
   default:
     Pike_fatal("hash(): Unsupported string shift: %d\n", s->size_shift);
     break;
+#endif
   }
 
   if(args > 1)
@@ -498,7 +500,7 @@ static struct case_info *find_ci_shift0(INT32 c)
       case CIM_UPPERDELTA: C = c + ci->data; break; \
       case CIM_CASEBIT: C = c | ci->data; break; \
       case CIM_CASEBITOFF: C = ((c - ci->data) | ci->data) + ci->data; break; \
-      default: Pike_fatal("lower_case(): Unknown case_info mode: %d\n", ci->mode); \
+      DO_IF_DEBUG( default: Pike_fatal("lower_case(): Unknown case_info mode: %d\n", ci->mode); ) \
     } \
    }} \
   } while(0)
@@ -513,7 +515,7 @@ static struct case_info *find_ci_shift0(INT32 c)
       case CIM_UPPERDELTA: C = c + ci->data; break; \
       case CIM_CASEBIT: C = c | ci->data; break; \
       case CIM_CASEBITOFF: C = ((c - ci->data) | ci->data) + ci->data; break; \
-      default: Pike_fatal("lower_case(): Unknown case_info mode: %d\n", ci->mode); \
+      DO_IF_DEBUG( default: Pike_fatal("lower_case(): Unknown case_info mode: %d\n", ci->mode); ) \
     } \
    }} \
   } while(0)
@@ -528,7 +530,7 @@ static struct case_info *find_ci_shift0(INT32 c)
       case CIM_LOWERDELTA: C = c - ci->data; break; \
       case CIM_CASEBIT: C = c & ~ci->data; break; \
       case CIM_CASEBITOFF: C = ((c - ci->data)& ~ci->data) + ci->data; break; \
-      default: Pike_fatal("upper_case(): Unknown case_info mode: %d\n", ci->mode); \
+      DO_IF_DEBUG( default: Pike_fatal("upper_case(): Unknown case_info mode: %d\n", ci->mode); ) \
     } \
    }} \
   } while(0)
@@ -543,7 +545,7 @@ static struct case_info *find_ci_shift0(INT32 c)
       case CIM_LOWERDELTA: C = c - ci->data; break; \
       case CIM_CASEBIT: C = c & ~ci->data; break; \
       case CIM_CASEBITOFF: C = ((c - ci->data)& ~ci->data) + ci->data; break; \
-      default: Pike_fatal("lower_case(): Unknown case_info mode: %d\n", ci->mode); \
+      DO_IF_DEBUG( default: Pike_fatal("lower_case(): Unknown case_info mode: %d\n", ci->mode); ) \
     } \
    }} \
   } while(0)
@@ -609,8 +611,10 @@ PMOD_EXPORT void f_lower_case(INT32 args)
     while(i--) {
       DO_LOWER_CASE(str[i]);
     }
+#ifdef PIKE_DEBUG
   } else {
     Pike_fatal("lower_case(): Bad string shift:%d\n", orig->size_shift);
+#endif
   }
 
   pop_n_elems(args);
@@ -706,8 +710,10 @@ PMOD_EXPORT void f_upper_case(INT32 args)
     while(i--) {
       DO_UPPER_CASE(str[i]);
     }
+#ifdef PIKE_DEBUG
   } else {
     Pike_fatal("lower_case(): Bad string shift:%d\n", orig->size_shift);
+#endif
   }
 
   pop_n_elems(args);
@@ -901,10 +907,12 @@ PMOD_EXPORT void f_search(INT32 args)
 	  }
 	}
 	break;
+#ifdef PIKE_DEBUG
       default:
 	Pike_fatal("search(): Unsupported string shift: %d!\n",
 	      haystack->size_shift);
 	break;
+#endif
       }
       if (start >= haystack->len) {
 	start = -1;
@@ -1607,9 +1615,11 @@ PMOD_EXPORT void f_string_to_unicode(INT32 args)
       out = end_shared_string(out);
     }
     break;
+#ifdef PIKE_DEBUG
   default:
-    Pike_error("string_to_unicode(): Bad string shift: %d!\n", in->size_shift);
+    Pike_fatal("string_to_unicode(): Bad string shift: %d!\n", in->size_shift);
     break;
+#endif
   }
   pop_n_elems(args);
   push_string(out);
diff --git a/src/cpp.c b/src/cpp.c
index c16692ca74..b837bb33e4 100644
--- a/src/cpp.c
+++ b/src/cpp.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: cpp.c,v 1.168 2008/05/01 20:39:40 mast Exp $
+|| $Id: cpp.c,v 1.169 2008/05/03 15:29:24 nilsson Exp $
 */
 
 #include "global.h"
@@ -517,9 +517,11 @@ static void check_defined(struct cpp *this,
   case 2:
     s = binary_findstring2((p_wchar2 *)args[0].arg.ptr, args[0].len);
     break;
+#ifdef PIKE_DEBUG
   default:
     Pike_fatal("cpp(): Symbol has unsupported shift: %d\n", args[0].arg.shift);
     break;
+#endif
   }
   if(s && find_define(s))
   {
@@ -1472,8 +1474,10 @@ static ptrdiff_t low_cpp(struct cpp *this, void *data, ptrdiff_t len,
   case 2:
     return lower_cpp2(this, (p_wchar2 *)data, len,
 		      flags, auto_convert, charset);
+#ifdef PIKE_DEBUG
   default:
     Pike_fatal("low_cpp(): Bad shift: %d\n", shift);
+#endif
   }
   /* NOT_REACHED */
   return 0;
diff --git a/src/encode.c b/src/encode.c
index ed0c23b36c..49b6e558c3 100644
--- a/src/encode.c
+++ b/src/encode.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: encode.c,v 1.264 2008/04/26 19:04:25 grubba Exp $
+|| $Id: encode.c,v 1.265 2008/05/03 15:29:24 nilsson Exp $
 */
 
 #include "global.h"
@@ -2548,8 +2548,10 @@ static INT32 decode_portable_bytecode(INT32 string_no)
 #undef SIGNED_CHAR
 #undef EMIT_BYTECODE
 #undef EMIT_BYTECODE2
+#ifdef PIKE_DEBUG
   default:
     Pike_fatal("Bad size_shift: %d\n", bytecode->size_shift);
+#endif
   }
   UNSET_ONERROR(err);
   return assemble(1);
diff --git a/src/iterators.cmod b/src/iterators.cmod
index ada3246068..363bd3a2f5 100644
--- a/src/iterators.cmod
+++ b/src/iterators.cmod
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: iterators.cmod,v 1.65 2008/05/01 21:33:24 mast Exp $
+|| $Id: iterators.cmod,v 1.66 2008/05/03 15:29:24 nilsson Exp $
 */
 
 #include "global.h"
@@ -1360,8 +1360,10 @@ PIKECLASS string_split_iterator
 	NEW_SKIP_CASE(0, ssi->flags);
 	NEW_SKIP_CASE(1, ssi->flags);
 	NEW_SKIP_CASE(2, ssi->flags);
+#ifdef PIKE_DEBUG
       default:
 	Pike_fatal("Unsupported size shift!\n");
+#endif
       }
     scan_more:
       switch(ssi->buffer->size_shift)
@@ -1369,8 +1371,10 @@ PIKECLASS string_split_iterator
 	NEW_SCAN_MORE_CASE(0);
 	NEW_SCAN_MORE_CASE(1);
 	NEW_SCAN_MORE_CASE(2);
+#ifdef PIKE_DEBUG
       default:
 	Pike_fatal("Unsupported size shift!\n");
+#endif
       }
     }
 
@@ -1474,17 +1478,21 @@ PIKECLASS string_split_iterator
 	      SIMPLE_SKIP_CASE(THIS, 0, off);
 	      SIMPLE_SKIP_CASE(THIS, 1, off);
 	      SIMPLE_SKIP_CASE(THIS, 2, off);
+#ifdef PIKE_DEBUG
 	    default:
 	      Pike_fatal("Unsupported size shift!\n");
+#endif
 	    }
 	  } else {
 	    switch(THIS->buffer->size_shift) {
 	      COMPLEX_SKIP_CASE(THIS, 0, off);
 	      COMPLEX_SKIP_CASE(THIS, 1, off);
 	      COMPLEX_SKIP_CASE(THIS, 2, off);
+#ifdef PIKE_DEBUG
 	    default:
 	      Pike_fatal("Unsupported size shift!\n");
-	    }	  
+#endif
+	    }
 	  }
 	  if (off >= THIS->buffer->len) {
 	    break;
@@ -1496,16 +1504,20 @@ PIKECLASS string_split_iterator
 	    SIMPLE_SCAN_CASE(THIS, 0, off);
 	    SIMPLE_SCAN_CASE(THIS, 1, off);
 	    SIMPLE_SCAN_CASE(THIS, 2, off);
+#ifdef PIKE_DEBUG
 	  default:
 	    Pike_fatal("Unsupported size shift!\n");
+#endif
 	  }
 	} else {
 	  switch(THIS->buffer->size_shift) {
 	    COMPLEX_SCAN_CASE(THIS, 0, off);
 	    COMPLEX_SCAN_CASE(THIS, 1, off);
 	    COMPLEX_SCAN_CASE(THIS, 2, off);
+#ifdef PIKE_DEBUG
 	  default:
 	    Pike_fatal("Unsupported size shift!\n");
+#endif
 	  }
 	}
       }
diff --git a/src/operators.c b/src/operators.c
index b1eee0939c..04289d12eb 100644
--- a/src/operators.c
+++ b/src/operators.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: operators.c,v 1.230 2008/04/14 10:14:40 grubba Exp $
+|| $Id: operators.c,v 1.231 2008/05/03 15:29:24 nilsson Exp $
 */
 
 #include "global.h"
@@ -446,10 +446,12 @@ PMOD_EXPORT void o_cast_to_string(void)
 	  }
 	}
 	break;
+#ifdef PIKE_DEBUG
       default:
 	free_string(end_shared_string(s));
 	Pike_fatal("cast: Bad shift: %d.\n", shift);
 	break;
+#endif
       }
       s = end_shared_string(s);
       pop_stack();
diff --git a/src/preprocessor.h b/src/preprocessor.h
index 0dad492da2..8973c2f7ed 100644
--- a/src/preprocessor.h
+++ b/src/preprocessor.h
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: preprocessor.h,v 1.92 2008/05/01 20:39:40 mast Exp $
+|| $Id: preprocessor.h,v 1.93 2008/05/03 15:29:24 nilsson Exp $
 */
 
 /*
@@ -1855,9 +1855,11 @@ static ptrdiff_t lower_cpp(struct cpp *this,
 	  case 2:
 	    calc_2(this, (p_wchar2 *)tmp.s->str, tmp.s->len, 0, 0);
 	    break;
+#ifdef PIKE_DEBUG
 	  default:
 	    Pike_fatal("cpp(): Bad shift: %d\n", tmp.s->size_shift);
 	    break;
+#endif
 	  }
 	  if(SAFE_IS_ZERO(Pike_sp-1)) nflags|=CPP_NO_OUTPUT;
 	  pop_stack();
@@ -1982,9 +1984,11 @@ static ptrdiff_t lower_cpp(struct cpp *this,
 	  case 2:
 	    calc_2(this, (p_wchar2 *)tmp.s->str, tmp.s->len,0,0);
 	    break;
+#ifdef PIKE_DEBUG
 	  default:
 	    Pike_fatal("cpp(): Bad shift: %d\n", tmp.s->size_shift);
 	    break;
+#endif
 	  }
 	  free_string_builder(&tmp);
 	  if(!SAFE_IS_ZERO(Pike_sp-1)) flags&=~CPP_NO_OUTPUT;
diff --git a/src/program.c b/src/program.c
index 0a24fa2a86..f92342f093 100644
--- a/src/program.c
+++ b/src/program.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: program.c,v 1.682 2008/05/02 10:56:06 grubba Exp $
+|| $Id: program.c,v 1.683 2008/05/03 15:29:25 nilsson Exp $
 */
 
 #include "global.h"
@@ -7449,9 +7449,11 @@ static void run_init(struct compilation *c)
     case 0: c->lex.current_lexer = yylex0; break;
     case 1: c->lex.current_lexer = yylex1; break;
     case 2: c->lex.current_lexer = yylex2; break;
+#ifdef PIKE_DEBUG
     default:
       Pike_fatal("Program has bad shift %d!\n", c->prog->size_shift);
       break;
+#endif
   }
 
   c->lex.pos=c->prog->str;
diff --git a/src/sscanf.c b/src/sscanf.c
index f84316f598..ef9549e6f1 100644
--- a/src/sscanf.c
+++ b/src/sscanf.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: sscanf.c,v 1.171 2008/05/01 20:38:11 mast Exp $
+|| $Id: sscanf.c,v 1.172 2008/05/03 15:29:25 nilsson Exp $
 */
 
 #include "global.h"
@@ -1390,10 +1390,12 @@ INT32 low_sscanf(struct pike_string *data, struct pike_string *format)
 			    STR2(format), format->len,
 			    &matched_chars, &x);
     break;
+#ifdef PIKE_DEBUG
   default:
     Pike_fatal("Unsupported shift-combination to low_sscanf(): %d:%d\n",
 	       data->size_shift, format->size_shift);
     break;
+#endif
   }
   return i;
 }
diff --git a/src/stralloc.c b/src/stralloc.c
index 0fc343e337..8cd3c9c4cf 100644
--- a/src/stralloc.c
+++ b/src/stralloc.c
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: stralloc.c,v 1.216 2008/05/02 04:15:16 mast Exp $
+|| $Id: stralloc.c,v 1.217 2008/05/03 15:29:26 nilsson Exp $
 */
 
 #include "global.h"
@@ -157,7 +157,9 @@ static INLINE unsigned INT32 generic_extract (const void *str, int size, ptrdiff
     case 1: return ((unsigned INT16 *)str)[pos];
     case 2: return ((unsigned INT32 *)str)[pos];
   }
+#ifdef PIKE_DEBUG
   Pike_fatal("Illegal shift size!\n");
+#endif
   return 0;
 }
 
@@ -202,8 +204,10 @@ PMOD_EXPORT void low_set_index(struct pike_string *s, ptrdiff_t pos,
     case 0: STR0(s)[pos]=value; break;
     case 1: STR1(s)[pos]=value; break;
     case 2: STR2(s)[pos]=value; break;
+#ifdef PIKE_DEBUG
     default:
       Pike_fatal("Illegal shift size!\n");
+#endif
   }
   s->flags |= STRING_NOT_HASHED;
 }
@@ -799,8 +803,10 @@ PMOD_EXPORT struct pike_string *end_shared_string(struct pike_string *s)
 
   switch(s->size_shift)
   {
+#ifdef PIKE_DEBUG
     default:
       Pike_fatal("ARGHEL! size_shift:%d\n", s->size_shift);
+#endif
 
     case 2:
       switch(find_magnitude2(STR2(s),s->len))
@@ -896,8 +902,10 @@ PMOD_EXPORT struct pike_string * debug_make_shared_binary_pcharp(const PCHARP st
       return make_shared_binary_string1((p_wchar1 *)(str.ptr),  len);
     case 2:
       return make_shared_binary_string2((p_wchar2 *)(str.ptr),  len);
+#ifdef PIKE_DEBUG
     default:
       Pike_fatal("Unknown string width!\n");
+#endif
   }
   /* NOT REACHED */
   return NULL;	/* Keep the compiler happy */
@@ -1683,8 +1691,10 @@ PMOD_EXPORT struct pike_string *modify_shared_string(struct pike_string *a,
 	free_string(a);
 	return end_shared_string(b);
 
+#ifdef PIKE_DEBUG
       default:
 	Pike_fatal("Odd wide string conversion!\n");
+#endif
     }
   }
 
@@ -1884,7 +1894,9 @@ PMOD_EXPORT struct pike_string *string_slice(struct pike_string *s,
     case 2:
       return make_shared_binary_string2(STR2(s)+start,len);
   }
+#ifdef PIKE_DEBUG
   Pike_fatal("Illegal shift size!\n");
+#endif
   return 0;
 }
 
@@ -3004,7 +3016,9 @@ PMOD_EXPORT PCHARP MEMCHR_PCHARP(PCHARP ptr, int chr, ptrdiff_t len)
     case 1: return MKPCHARP(MEMCHR1((p_wchar1 *)ptr.ptr,chr,len),1);
     case 2: return MKPCHARP(MEMCHR2((p_wchar2 *)ptr.ptr,chr,len),2);
   }
+#ifdef PIKE_DEBUG
   Pike_fatal("Illegal shift in MEMCHR_PCHARP.\n");
+#endif
   return MKPCHARP(0,0); /* make wcc happy */
 }
 
@@ -3447,8 +3461,10 @@ PMOD_EXPORT p_wchar0 *require_wstring0(struct pike_string *s,
     case 2:
       return 0;
 
+#ifdef PIKE_DEBUG
     default:
       Pike_fatal("Illegal shift size in string.\n");
+#endif
   }
   return 0;
 }
@@ -3470,8 +3486,10 @@ PMOD_EXPORT p_wchar1 *require_wstring1(struct pike_string *s,
     case 2:
       return 0;
 
+#ifdef PIKE_DEBUG
     default:
       Pike_fatal("Illegal shift size in string.\n");
+#endif
   }
   return 0;
 }
@@ -3496,8 +3514,10 @@ PMOD_EXPORT p_wchar2 *require_wstring2(struct pike_string *s,
       *to_free=0;
       return STR2(s);
 
+#ifdef PIKE_DEBUG
     default:
       Pike_fatal("Illegal shift size in string.\n");
+#endif
   }
   return 0;
 }
-- 
GitLab