Commit 37ac9db3 authored by Morten Welinder's avatar Morten Welinder

Fix toupper/tolower applications.

Fix PROPER.
parent baffe5d1
1999-06-12 Morten Welinder <terra@diku.dk>
* src/utils.c (gnumeric_strcase_hash): Use unsigned chars.
(col_from_name): Ditto.
* src/format.c (append_year): Ditto.
(append_month): Ditto.
(append_hour): Ditto.
(append_day): Ditto.
(append_minute): Ditto.
(append_second): Ditto.
(pre_parse_format): Ditto.
* src/number-match.c (format_create_regexp): Ditto.
* src/fn-string.c (gnumeric_lower): Use g_strdup to match g_free.
(gnumeric_upper): Ditto.
(gnumeric_lower): Use unsigned chars. (This fixes problems with
non-English letters.)
(gnumeric_upper): Ditto.
(gnumeric_proper): Ditto. Operate on a _copy_ of the string, not
the source string itself!
1999-06-10 Morten Welinder <terra@diku.dk>
* src/parser.y (return_cellref): Surprise: isdigit and friends
......
1999-06-12 Morten Welinder <terra@diku.dk>
* src/utils.c (gnumeric_strcase_hash): Use unsigned chars.
(col_from_name): Ditto.
* src/format.c (append_year): Ditto.
(append_month): Ditto.
(append_hour): Ditto.
(append_day): Ditto.
(append_minute): Ditto.
(append_second): Ditto.
(pre_parse_format): Ditto.
* src/number-match.c (format_create_regexp): Ditto.
* src/fn-string.c (gnumeric_lower): Use g_strdup to match g_free.
(gnumeric_upper): Ditto.
(gnumeric_lower): Use unsigned chars. (This fixes problems with
non-English letters.)
(gnumeric_upper): Ditto.
(gnumeric_proper): Ditto. Operate on a _copy_ of the string, not
the source string itself!
1999-06-10 Morten Welinder <terra@diku.dk>
* src/parser.y (return_cellref): Surprise: isdigit and friends
......
1999-06-12 Morten Welinder <terra@diku.dk>
* src/utils.c (gnumeric_strcase_hash): Use unsigned chars.
(col_from_name): Ditto.
* src/format.c (append_year): Ditto.
(append_month): Ditto.
(append_hour): Ditto.
(append_day): Ditto.
(append_minute): Ditto.
(append_second): Ditto.
(pre_parse_format): Ditto.
* src/number-match.c (format_create_regexp): Ditto.
* src/fn-string.c (gnumeric_lower): Use g_strdup to match g_free.
(gnumeric_upper): Ditto.
(gnumeric_lower): Use unsigned chars. (This fixes problems with
non-English letters.)
(gnumeric_upper): Ditto.
(gnumeric_proper): Ditto. Operate on a _copy_ of the string, not
the source string itself!
1999-06-10 Morten Welinder <terra@diku.dk>
* src/parser.y (return_cellref): Surprise: isdigit and friends
......
1999-06-12 Morten Welinder <terra@diku.dk>
* src/utils.c (gnumeric_strcase_hash): Use unsigned chars.
(col_from_name): Ditto.
* src/format.c (append_year): Ditto.
(append_month): Ditto.
(append_hour): Ditto.
(append_day): Ditto.
(append_minute): Ditto.
(append_second): Ditto.
(pre_parse_format): Ditto.
* src/number-match.c (format_create_regexp): Ditto.
* src/fn-string.c (gnumeric_lower): Use g_strdup to match g_free.
(gnumeric_upper): Ditto.
(gnumeric_lower): Use unsigned chars. (This fixes problems with
non-English letters.)
(gnumeric_upper): Ditto.
(gnumeric_proper): Ditto. Operate on a _copy_ of the string, not
the source string itself!
1999-06-10 Morten Welinder <terra@diku.dk>
* src/parser.y (return_cellref): Surprise: isdigit and friends
......
......@@ -161,7 +161,7 @@ gnumeric_lower (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
Value *v;
char *s, *p;
unsigned char *s, *p;
if (argv [0]->type != VALUE_STRING){
*error_string = _("Type mismatch");
......@@ -170,7 +170,7 @@ gnumeric_lower (struct FunctionDefinition *i,
v = g_new (Value, 1);
v->type = VALUE_STRING;
p = s = strdup (argv [0]->v.str->str);
p = s = g_strdup (argv [0]->v.str->str);
for (; *p; p++){
*p = tolower (*p);
}
......@@ -280,7 +280,7 @@ gnumeric_upper (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
Value *v;
char *s, *p;
unsigned char *s, *p;
if (argv [0]->type != VALUE_STRING){
*error_string = _("Type mismatch");
......@@ -289,7 +289,7 @@ gnumeric_upper (struct FunctionDefinition *i,
v = g_new (Value, 1);
v->type = VALUE_STRING;
p = s = strdup (argv [0]->v.str->str);
p = s = g_strdup (argv [0]->v.str->str);
for (;*p; p++){
*p = toupper (*p);
......@@ -596,7 +596,7 @@ gnumeric_proper (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
Value *v;
gchar *s, *p;
unsigned char *s, *p;
gboolean inword = FALSE;
if (argv [0]->type != VALUE_STRING) {
......@@ -604,9 +604,9 @@ gnumeric_proper (struct FunctionDefinition *i,
return NULL;
}
s = p = argv[0]->v.str->str;
s = p = g_strdup (argv[0]->v.str->str);
while (*s) {
if (isalpha((unsigned char)*s)) {
if (isalpha(*s)) {
if (inword) {
*s = tolower(*s);
} else {
......@@ -621,6 +621,7 @@ gnumeric_proper (struct FunctionDefinition *i,
v = g_new (Value, 1);
v->type = VALUE_STRING;
v->v.str = string_get (p);
g_free (p);
return v;
}
......
......@@ -161,7 +161,7 @@ gnumeric_lower (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
Value *v;
char *s, *p;
unsigned char *s, *p;
if (argv [0]->type != VALUE_STRING){
*error_string = _("Type mismatch");
......@@ -170,7 +170,7 @@ gnumeric_lower (struct FunctionDefinition *i,
v = g_new (Value, 1);
v->type = VALUE_STRING;
p = s = strdup (argv [0]->v.str->str);
p = s = g_strdup (argv [0]->v.str->str);
for (; *p; p++){
*p = tolower (*p);
}
......@@ -280,7 +280,7 @@ gnumeric_upper (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
Value *v;
char *s, *p;
unsigned char *s, *p;
if (argv [0]->type != VALUE_STRING){
*error_string = _("Type mismatch");
......@@ -289,7 +289,7 @@ gnumeric_upper (struct FunctionDefinition *i,
v = g_new (Value, 1);
v->type = VALUE_STRING;
p = s = strdup (argv [0]->v.str->str);
p = s = g_strdup (argv [0]->v.str->str);
for (;*p; p++){
*p = toupper (*p);
......@@ -596,7 +596,7 @@ gnumeric_proper (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
Value *v;
gchar *s, *p;
unsigned char *s, *p;
gboolean inword = FALSE;
if (argv [0]->type != VALUE_STRING) {
......@@ -604,9 +604,9 @@ gnumeric_proper (struct FunctionDefinition *i,
return NULL;
}
s = p = argv[0]->v.str->str;
s = p = g_strdup (argv[0]->v.str->str);
while (*s) {
if (isalpha((unsigned char)*s)) {
if (isalpha(*s)) {
if (inword) {
*s = tolower(*s);
} else {
......@@ -621,6 +621,7 @@ gnumeric_proper (struct FunctionDefinition *i,
v = g_new (Value, 1);
v->type = VALUE_STRING;
v->v.str = string_get (p);
g_free (p);
return v;
}
......
......@@ -72,7 +72,7 @@ static void style_entry_free (gpointer data, gpointer user_data);
* number of characters used.
*/
static int
append_year (GString *string, const gchar *format, const struct tm *time_split)
append_year (GString *string, const guchar *format, const struct tm *time_split)
{
char temp [5];
......@@ -98,7 +98,7 @@ append_year (GString *string, const gchar *format, const struct tm *time_split)
* number of characters used.
*/
static int
append_month (GString *string, const gchar *format, const struct tm *time_split)
append_month (GString *string, const guchar *format, const struct tm *time_split)
{
char temp [3];
......@@ -129,7 +129,7 @@ append_month (GString *string, const gchar *format, const struct tm *time_split)
* number of characters used.
*/
static int
append_hour (GString *string, const gchar *format, const struct tm *time_split, int timeformat)
append_hour (GString *string, const guchar *format, const struct tm *time_split, int timeformat)
{
char temp[3];
......@@ -148,7 +148,7 @@ append_hour (GString *string, const gchar *format, const struct tm *time_split,
* number of characters used.
*/
static int
append_day (GString *string, const gchar *format, const struct tm *time_split)
append_day (GString *string, const guchar *format, const struct tm *time_split)
{
char temp[3];
......@@ -179,7 +179,7 @@ append_day (GString *string, const gchar *format, const struct tm *time_split)
* number of characters used.
*/
static int
append_minute (GString *string, const gchar *format, const struct tm *time_split)
append_minute (GString *string, const guchar *format, const struct tm *time_split)
{
char temp [3];
......@@ -200,7 +200,7 @@ append_minute (GString *string, const gchar *format, const struct tm *time_split
* number of characters used.
*/
static int
append_second (GString *string, const gchar *format, const struct tm *time_split)
append_second (GString *string, const guchar *format, const struct tm *time_split)
{
char temp[3];
......@@ -222,7 +222,7 @@ append_second (GString *string, const gchar *format, const struct tm *time_split
* the number of characters used.
*/
static int
append_half (GString *string, const gchar *format, const struct tm *time_split)
append_half (GString *string, const guchar *format, const struct tm *time_split)
{
if (time_split->tm_hour <= 11){
if (tolower (format [0]) == 'a' || tolower (format [0]) == 'p')
......@@ -252,7 +252,7 @@ append_half (GString *string, const gchar *format, const struct tm *time_split)
static void
pre_parse_format (StyleFormatEntry *style)
{
const char *format;
const unsigned char *format;
style->want_am_pm = 0;
for (format = style->format; *format; format++){
......
......@@ -161,7 +161,7 @@ gnumeric_lower (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
Value *v;
char *s, *p;
unsigned char *s, *p;
if (argv [0]->type != VALUE_STRING){
*error_string = _("Type mismatch");
......@@ -170,7 +170,7 @@ gnumeric_lower (struct FunctionDefinition *i,
v = g_new (Value, 1);
v->type = VALUE_STRING;
p = s = strdup (argv [0]->v.str->str);
p = s = g_strdup (argv [0]->v.str->str);
for (; *p; p++){
*p = tolower (*p);
}
......@@ -280,7 +280,7 @@ gnumeric_upper (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
Value *v;
char *s, *p;
unsigned char *s, *p;
if (argv [0]->type != VALUE_STRING){
*error_string = _("Type mismatch");
......@@ -289,7 +289,7 @@ gnumeric_upper (struct FunctionDefinition *i,
v = g_new (Value, 1);
v->type = VALUE_STRING;
p = s = strdup (argv [0]->v.str->str);
p = s = g_strdup (argv [0]->v.str->str);
for (;*p; p++){
*p = toupper (*p);
......@@ -596,7 +596,7 @@ gnumeric_proper (struct FunctionDefinition *i,
Value *argv [], char **error_string)
{
Value *v;
gchar *s, *p;
unsigned char *s, *p;
gboolean inword = FALSE;
if (argv [0]->type != VALUE_STRING) {
......@@ -604,9 +604,9 @@ gnumeric_proper (struct FunctionDefinition *i,
return NULL;
}
s = p = argv[0]->v.str->str;
s = p = g_strdup (argv[0]->v.str->str);
while (*s) {
if (isalpha((unsigned char)*s)) {
if (isalpha(*s)) {
if (inword) {
*s = tolower(*s);
} else {
......@@ -621,6 +621,7 @@ gnumeric_proper (struct FunctionDefinition *i,
v = g_new (Value, 1);
v->type = VALUE_STRING;
v->v.str = string_get (p);
g_free (p);
return v;
}
......
......@@ -124,11 +124,11 @@ col_from_name (const char *cell_str)
char c;
int col = 0;
c = toupper (*cell_str++);
c = toupper ((unsigned char)*cell_str++);
if (c < 'A' || c > 'Z')
return FALSE;
col = c - 'A';
c = toupper (*cell_str);
c = toupper ((unsigned char)*cell_str);
if (c >= 'A' && c <= 'Z')
col = ((col + 1) * ('Z' - 'A' + 1)) + (c - 'A');
if (col >= SHEET_MAX_COLS)
......@@ -151,11 +151,11 @@ parse_cell_name (const char *cell_str, int *col, int *row)
char c;
/* Parse column name: one or two letters. */
c = toupper (*cell_str++);
c = toupper ((unsigned char)*cell_str++);
if (c < 'A' || c > 'Z')
return FALSE;
*col = c - 'A';
c = toupper (*cell_str);
c = toupper ((unsigned char)*cell_str);
if (c >= 'A' && c <= 'Z') {
*col = ((*col + 1) * ('Z' - 'A' + 1)) + (c - 'A');
cell_str++;
......@@ -189,8 +189,8 @@ gnumeric_strcase_equal (gconstpointer v, gconstpointer v2)
guint
gnumeric_strcase_hash (gconstpointer v)
{
const char *s = (const char*)v;
const char *p;
const unsigned char *s = (const unsigned char*)v;
const unsigned char *p;
guint h=0, g;
for(p = s; *p != '\0'; p += 1) {
......
......@@ -84,7 +84,7 @@ typedef enum {
#define append_type(t) do { guint8 x = t; match_types = g_byte_array_append (match_types, &x, 1); } while (0)
static char *
format_create_regexp (const char *format, GByteArray **dest)
format_create_regexp (const unsigned char *format, GByteArray **dest)
{
GString *regexp;
GByteArray *match_types;
......@@ -289,7 +289,7 @@ format_create_regexp (const char *format, GByteArray **dest)
/* Matches a string */
case '"': {
const char *p;
const unsigned char *p;
char *buf;
for (p = format+1; *p && *p != '"'; p++)
......
......@@ -124,11 +124,11 @@ col_from_name (const char *cell_str)
char c;
int col = 0;
c = toupper (*cell_str++);
c = toupper ((unsigned char)*cell_str++);
if (c < 'A' || c > 'Z')
return FALSE;
col = c - 'A';
c = toupper (*cell_str);
c = toupper ((unsigned char)*cell_str);
if (c >= 'A' && c <= 'Z')
col = ((col + 1) * ('Z' - 'A' + 1)) + (c - 'A');
if (col >= SHEET_MAX_COLS)
......@@ -151,11 +151,11 @@ parse_cell_name (const char *cell_str, int *col, int *row)
char c;
/* Parse column name: one or two letters. */
c = toupper (*cell_str++);
c = toupper ((unsigned char)*cell_str++);
if (c < 'A' || c > 'Z')
return FALSE;
*col = c - 'A';
c = toupper (*cell_str);
c = toupper ((unsigned char)*cell_str);
if (c >= 'A' && c <= 'Z') {
*col = ((*col + 1) * ('Z' - 'A' + 1)) + (c - 'A');
cell_str++;
......@@ -189,8 +189,8 @@ gnumeric_strcase_equal (gconstpointer v, gconstpointer v2)
guint
gnumeric_strcase_hash (gconstpointer v)
{
const char *s = (const char*)v;
const char *p;
const unsigned char *s = (const unsigned char*)v;
const unsigned char *p;
guint h=0, g;
for(p = s; *p != '\0'; p += 1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment