From 17cadc50ecfc2251a4a73398e6befe3162a77e9c Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Fri, 7 Dec 2012 14:32:46 +0400 Subject: [PATCH] Portability: use g_ascii_strtoll instead of strtoll, atoll and atof. Set minimal version of GLib up to 2.12 because of g_ascii_strtoll. Signed-off-by: Andrew Borodin --- configure.ac | 1 - lib/util.c | 2 +- lib/vfs/parse_ls_vga.c | 6 +----- m4.include/ac-glib.m4 | 8 ++++---- src/vfs/fish/fish.c | 8 ++------ src/viewer/dialogs.c | 2 +- 6 files changed, 9 insertions(+), 18 deletions(-) diff --git a/configure.ac b/configure.ac index 71ef7d9bd..fdece2791 100644 --- a/configure.ac +++ b/configure.ac @@ -226,7 +226,6 @@ dnl Check for functions dnl ############################################################################ AC_CHECK_FUNCS([\ - atoll \ isascii \ statfs sysconf \ tcgetattr tcsetattr \ diff --git a/lib/util.c b/lib/util.c index 2ea57f769..3a77de2e3 100644 --- a/lib/util.c +++ b/lib/util.c @@ -1148,7 +1148,7 @@ load_file_position (const vfs_path_t * filename_vpath, long *line, long *column, { size_t i; - *offset = strtoll (pos_tokens[2], NULL, 10); + *offset = (off_t) g_ascii_strtoll (pos_tokens[2], NULL, 10); for (i = 0; i < MAX_SAVED_BOOKMARKS && pos_tokens[3 + i] != NULL; i++) { diff --git a/lib/vfs/parse_ls_vga.c b/lib/vfs/parse_ls_vga.c index e5f7d6232..98a0e88af 100644 --- a/lib/vfs/parse_ls_vga.c +++ b/lib/vfs/parse_ls_vga.c @@ -778,11 +778,7 @@ vfs_parse_ls_lga (const char *p, struct stat * s, char **filename, char **linkna if (!is_num (idx2)) goto error; -#ifdef HAVE_ATOLL - s->st_size = (off_t) atoll (columns[idx2]); -#else - s->st_size = (off_t) atof (columns[idx2]); -#endif + s->st_size = (off_t) g_ascii_strtoll (columns[idx2], NULL, 10); #ifdef HAVE_STRUCT_STAT_ST_RDEV s->st_rdev = 0; #endif diff --git a/m4.include/ac-glib.m4 b/m4.include/ac-glib.m4 index 2277dfa06..9d35d1c29 100644 --- a/m4.include/ac-glib.m4 +++ b/m4.include/ac-glib.m4 @@ -8,12 +8,12 @@ AC_DEFUN([AC_G_MODULE_SUPPORTED], [ g_module_supported="" found_gmodule=no - PKG_CHECK_MODULES(GMODULE, [gmodule-no-export-2.0 >= 2.8], [found_gmodule=yes], [:]) + PKG_CHECK_MODULES(GMODULE, [gmodule-no-export-2.0 >= 2.12], [found_gmodule=yes], [:]) if test x"$found_gmodule" = xyes; then g_module_supported="gmodule-no-export-2.0" else dnl try fallback to the generic gmodule - PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.8], [found_gmodule=yes], [:]) + PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.12], [found_gmodule=yes], [:]) if test x"$found_gmodule" = xyes; then g_module_supported="gmodule-2.0" fi @@ -80,9 +80,9 @@ AC_DEFUN([AC_CHECK_GLIB], [ AS_HELP_STRING([--with-glib-static], [Link glib statically @<:@no@:>@])) glib_found=no - PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.8], [glib_found=yes], [:]) + PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.12], [glib_found=yes], [:]) if test x"$glib_found" = xno; then - AC_MSG_ERROR([glib-2.0 not found or version too old (must be >= 2.8)]) + AC_MSG_ERROR([glib-2.0 not found or version too old (must be >= 2.12)]) fi ]) diff --git a/src/vfs/fish/fish.c b/src/vfs/fish/fish.c index d372b125f..5c84175f4 100644 --- a/src/vfs/fish/fish.c +++ b/src/vfs/fish/fish.c @@ -778,11 +778,7 @@ fish_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path) break; } case 'S': -#ifdef HAVE_ATOLL - ST.st_size = (off_t) atoll (buffer + 1); -#else - ST.st_size = (off_t) atof (buffer + 1); -#endif + ST.st_size = (off_t) g_ascii_strtoll (buffer + 1, NULL, 10); break; case 'P': { @@ -1016,7 +1012,7 @@ fish_linear_start (struct vfs_class *me, vfs_file_handler_t * fh, off_t offset) #if SIZEOF_OFF_T == SIZEOF_LONG fish->total = (off_t) strtol (reply_str, NULL, 10); #else - fish->total = (off_t) strtoll (reply_str, NULL, 10); + fish->total = (off_t) g_ascii_strtoll (reply_str, NULL, 10); #endif if (errno != 0) ERRNOR (E_REMOTE, 0); diff --git a/src/viewer/dialogs.c b/src/viewer/dialogs.c index e56dc364e..7a251bb49 100644 --- a/src/viewer/dialogs.c +++ b/src/viewer/dialogs.c @@ -225,7 +225,7 @@ mcview_dialog_goto (mcview_t * view, off_t * offset) off_t addr; char *error; - addr = strtoll (exp, &error, base); + addr = (off_t) g_ascii_strtoll (exp, &error, base); if ((*error == '\0') && (addr >= 0)) { switch (current_goto_type)