Browse Source

Implement portable CalcTolower instead of relying on system tolower for names in the calculator charset.

git-svn-id: file:///var/svn/tigccpp/trunk/tigcc/ld-tigcc@1160 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler 17 years ago
parent
commit
ee6e19fa55
2 changed files with 17 additions and 6 deletions
  1. 11 0
      main.c
  2. 6 6
      main_opt.inc

+ 11 - 0
main.c

@@ -79,6 +79,17 @@ static void DecodeOnCalcName(char *Dest, const char *Src)
 	strncpy (Dest, Src, MAX_NAME_LEN);
 }
 
+// Maps uppercase characters in the calculator charset to lowercase.
+// This matches AMS conversion rules, so Greek letters are not converted.
+static char CalcTolower(char Lower)
+{
+	unsigned char c = Lower;
+	if ((c >= 'A' && c <= 'Z')
+	    || (c >= 192 && c <= 222 && c != 215))
+		c -= 32;
+	return c;
+}
+
 int main (int ArgCount, const char **Args)
 {
 	OPTIMIZE_INFO _OptimizeInfo;

+ 6 - 6
main_opt.inc

@@ -214,7 +214,7 @@
 									*S = 0;
 								// Convert to lowercase.
 								for (S = ProgramName; *S; S++)
-									*S = tolower (*S);
+									*S = CalcTolower (*S);
 							}
 						}
 					}
@@ -254,7 +254,7 @@
 										break;
 									}
 									else
-										*S = tolower (*S);
+										*S = CalcTolower (*S);
 								}
 							}
 						}
@@ -264,7 +264,7 @@
 						{
 							char *S;
 							for (S = ProgramName; *S; S++)
-								*S = tolower (*S);
+								*S = CalcTolower (*S);
 						}
 					}
 					else
@@ -294,7 +294,7 @@
 										break;
 									}
 									else
-										*S = tolower (*S);
+										*S = CalcTolower (*S);
 								}
 							}
 							sprintf (DataVarString, "%s\\", DataFolder);
@@ -308,7 +308,7 @@
 						{
 							char *S;
 							for (S = DataName; *S; S++)
-								*S = tolower (*S);
+								*S = CalcTolower (*S);
 						}
 						strcat (DataVarString, DataName);
 						DatVarInfo->Name = DataVarString;
@@ -448,7 +448,7 @@
 				*S = 0;
 			// Convert to lowercase.
 			for (S = ProgramName; *S; S++)
-				*S = tolower (*S);
+				*S = CalcTolower (*S);
 		}
 	}
 }