Commit 77d2d67a authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Eliminate tolower and make utf8 safe. Hopefully. (append_year): Ditto.

2002-10-18  Morten Welinder  <terra@diku.dk>

	* src/format.c (format_month_before_day): Eliminate tolower and
	make utf8 safe.  Hopefully.
	(append_year): Ditto.
	(append_day): Ditto.
	(format_compile): Ditto.
	(format_number): Ditto.
	* src/number-match.c (format_create_regexp): Ditto.
parent 620c3817
2002-10-18 Morten Welinder <terra@diku.dk>
* src/format.c (format_month_before_day): Eliminate tolower and
make utf8 safe. Hopefully.
(append_year): Ditto.
(append_day): Ditto.
(format_compile): Ditto.
(format_number): Ditto.
* src/number-match.c (format_create_regexp): Ditto.
2002-10-18 Morten Welinder <terra@diku.dk>
* src/sheet.c (sheet_name_quote): Make this utf8 safe.
......
2002-10-18 Morten Welinder <terra@diku.dk>
* src/format.c (format_month_before_day): Eliminate tolower and
make utf8 safe. Hopefully.
(append_year): Ditto.
(append_day): Ditto.
(format_compile): Ditto.
(format_number): Ditto.
* src/number-match.c (format_create_regexp): Ditto.
2002-10-18 Morten Welinder <terra@diku.dk>
* src/sheet.c (sheet_name_quote): Make this utf8 safe.
......
2002-10-18 Morten Welinder <terra@diku.dk>
* src/format.c (format_month_before_day): Eliminate tolower and
make utf8 safe. Hopefully.
(append_year): Ditto.
(append_day): Ditto.
(format_compile): Ditto.
(format_number): Ditto.
* src/number-match.c (format_create_regexp): Ditto.
2002-10-18 Morten Welinder <terra@diku.dk>
* src/sheet.c (sheet_name_quote): Make this utf8 safe.
......
......@@ -39,7 +39,6 @@
#include "formats.h"
#include <locale.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
......@@ -147,11 +146,11 @@ format_month_before_day (void)
month_first = TRUE;
if (ptr)
while (*ptr) {
char const tmp = tolower((unsigned char)*ptr++);
if (tmp == 'd') {
char c = *ptr++;
if (c == 'd' || c == 'D') {
month_first = FALSE;
break;
} else if (tmp == 'm')
} else if (c == 'm' || c == 'M')
break;
}
}
......@@ -226,19 +225,21 @@ static int
append_year (GString *string, const guchar *format, const struct tm *time_split)
{
char temp[5];
int year = time_split->tm_year + 1900;
if (tolower (format[1]) != 'y'){
if (format[1] != 'y' && format[1] != 'Y') {
g_string_append_c (string, 'y');
return 1;
}
if (tolower (format[2]) != 'y' || tolower (format[3]) != 'y'){
sprintf (temp, "%02d", time_split->tm_year % 100);
if ((format[2] != 'y' && format[2] != 'Y') ||
(format[3] != 'y' && format[3] != 'Y')) {
sprintf (temp, "%02d", year % 100);
g_string_append (string, temp);
return 2;
}
sprintf (temp, "%04d", time_split->tm_year + 1900);
sprintf (temp, "%04d", year);
g_string_append (string, temp);
return 4;
......@@ -283,19 +284,19 @@ append_day (GString *string, const guchar *format, const struct tm *time_split)
{
char temp[3];
if (tolower (format[1]) != 'd'){
if (format[1] != 'd' && format[1] != 'D') {
sprintf (temp, "%d", time_split->tm_mday);
g_string_append (string, temp);
return 1;
}
if (tolower (format[2]) != 'd'){
if (format[2] != 'd' && format[2] != 'D') {
sprintf (temp, "%02d", time_split->tm_mday);
g_string_append (string, temp);
return 2;
}
if (tolower (format[3]) != 'd'){
if (format[3] != 'd' && format[3] != 'D') {
g_string_append (string, _(day_short[time_split->tm_wday]) + 1);
return 3;
}
......@@ -517,7 +518,7 @@ format_compile (StyleFormat *format)
}
case '/':
if (fmt[1] == '?' || isdigit ((unsigned char)fmt[1])) {
if (fmt[1] == '?' || (fmt[1] >= '0' && fmt[1] <= '9')) {
entry->has_fraction = TRUE;
fmt++;
}
......@@ -525,7 +526,7 @@ format_compile (StyleFormat *format)
case 'a': case 'A':
case 'p': case 'P':
if (tolower (fmt[1]) == 'm')
if (fmt[1] == 'm' || fmt[1] == 'M')
entry->want_am_pm = TRUE;
break;
......@@ -1253,7 +1254,8 @@ format_number (gnum_float number, int col_width, StyleFormatEntry const *entry)
ignore_further_elapsed = TRUE;
append_minute_elapsed (result, time_split, number);
} else if (hour_seen ||
(format[1] == ':' && tolower (format[2]) == 's')){
(format[1] == ':' &&
(format[2] == 's' || format[2] == 'S'))) {
append_minute (result, n, time_split);
} else
append_month (result, n, time_split);
......
......@@ -32,7 +32,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <locale.h>
#include <math.h>
......@@ -152,7 +151,7 @@ format_create_regexp (char const *format, GByteArray **dest)
break;
case 'P': case 'p':
if (tolower (*(format + 1)) == 'm')
if (format[1] == 'm' || format[1] == 'M')
format++;
break;
......@@ -257,7 +256,7 @@ format_create_regexp (char const *format, GByteArray **dest)
case 'h':
case 'H':
hour_seen = TRUE;
if (tolower (*(format + 1)) == 'h')
if (format[1] == 'h' || format[1] == 'H')
format++;
g_string_append (regexp, "([0-9][0-9]?)");
......@@ -267,15 +266,15 @@ format_create_regexp (char const *format, GByteArray **dest)
case 'M':
case 'm':
if (hour_seen) {
if (tolower (*(format + 1)) == 'm')
if (format[1] == 'm' || format[1] == 'M')
format++;
g_string_append (regexp, "([0-9][0-9]?)");
append_type (MATCH_MINUTE);
hour_seen = FALSE;
} else {
if (tolower (*(format + 1)) == 'm') {
if (tolower (*(format + 2)) == 'm') {
if (tolower (*(format + 3)) == 'm') {
if (format[1] == 'm' || format[1] == 'M') {
if (format[2] == 'm' || format[2] == 'M') {
if (format[3] == 'm' || format[3] == 'M') {
char *l;
l = create_option_list (month_long);
......@@ -318,7 +317,7 @@ format_create_regexp (char const *format, GByteArray **dest)
match_types->data[l - 1] = MATCH_MINUTE;
}
if (tolower (*(format + 1) == 's'))
if (format[1] == 's' || format[1] == 'S')
format++;
g_string_append (regexp, "([0-9][0-9]?)");
append_type (MATCH_SECOND);
......@@ -326,9 +325,9 @@ format_create_regexp (char const *format, GByteArray **dest)
case 'D':
case 'd':
if (tolower (*(format + 1) == 'd')) {
if (tolower (*(format + 2) == 'd')) {
if (tolower (*(format + 3) == 'd')) {
if (format[1] == 'd' || format[1] == 'D') {
if (format[2] == 'd' || format[2] == 'D') {
if (format[3] == 'd' || format[3] == 'D') {
char *l;
l = create_option_list (day_long);
......@@ -358,9 +357,9 @@ format_create_regexp (char const *format, GByteArray **dest)
case 'Y':
case 'y':
if (tolower (*(format + 1) == 'y')) {
if (tolower (*(format + 2) == 'y')) {
if (tolower (*(format + 3) == 'y')) {
if (format[1] == 'y' || format[1] == 'Y') {
if (format[2] == 'y' || format[2] == 'Y') {
if (format[3] == 'y' || format[3] == 'Y') {
g_string_append (regexp, "([0-9][0-9][0-9][0-9])");
append_type (MATCH_YEAR_FULL);
format++;
......@@ -957,7 +956,7 @@ compute_value (char const *s, const regmatch_t *mp,
break;
case MATCH_AMPM:
if (tolower ((unsigned char) *str) == 'p')
if (*str == 'p' || *str == 'P')
is_pm = TRUE;
else
is_explicit_am = TRUE;
......
......@@ -23,7 +23,6 @@
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#ifndef MAP_PRIVATE
/* For the benefit of HPUX */
......@@ -60,7 +59,7 @@ gnumeric_fopen (IOContext *context, const char *path, const char *mode)
if (f != NULL)
return f;
if (mode != NULL && tolower (*mode) == 'r')
if (mode != NULL && (*mode == 'r' || *mode == 'R'))
gnumeric_error_read (COMMAND_CONTEXT (context), g_strerror (errno));
else
gnumeric_error_save (COMMAND_CONTEXT (context), g_strerror (errno));
......
2002-10-18 Morten Welinder <terra@diku.dk>
* gnumeric-expr-entry.c (gnm_expr_entry_rangesel_start): Use
g_unichar_isalnum.
2002-10-05 Jody Goldberg <jody@gnome.org>
* gnumeric-expr-entry.c (gnm_expr_entry_rangesel_start) : expressions
......
......@@ -32,7 +32,6 @@
#include <gtk/gtkentry.h>
#include <gtk/gtkcelleditable.h>
#include <gdk/gdkkeysyms.h>
#include <ctype.h>
#include <stdio.h>
typedef struct {
......@@ -436,7 +435,7 @@ gnm_expr_entry_rangesel_start (GnumericExprEntry *gee)
} else {
for (tmp = cursor; tmp > text; tmp = g_utf8_prev_char (tmp)) {
gunichar c = g_utf8_get_char (tmp);
if (!isalnum (c)) {
if (!g_unichar_isalnum (c)) {
tmp = g_utf8_next_char (tmp);
break;
}
......
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