From bcb8c376efac11e8a591e3e5fc0e0bb0ce9f06dc 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 cccbbd142..98061daef 100644 --- a/configure.ac +++ b/configure.ac @@ -162,7 +162,6 @@ dnl Check availability of some functions dnl AC_CHECK_FUNCS([\ - atoll \ isascii \ statfs sysconf \ tcgetattr tcsetattr \ diff --git a/lib/util.c b/lib/util.c index a56e2c83e..31e5fed27 100644 --- a/lib/util.c +++ b/lib/util.c @@ -1145,7 +1145,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 535314ad3..281501f4b 100644 --- a/m4.include/ac-glib.m4 +++ b/m4.include/ac-glib.m4 @@ -10,12 +10,12 @@ AC_DEFUN([AC_G_MODULE_SUPPORTED], [ textmode_x11_support="no" else 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 @@ -89,9 +89,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 5c466d5af..1950d2721 100644 --- a/src/vfs/fish/fish.c +++ b/src/vfs/fish/fish.c @@ -779,11 +779,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': { @@ -1017,7 +1013,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 70ff4d73f..396667174 100644 --- a/src/viewer/dialogs.c +++ b/src/viewer/dialogs.c @@ -260,7 +260,7 @@ mcview_dialog_goto (mcview_t * view, off_t * offset) res = TRUE; - addr = strtoll (exp, &error, base); + addr = (off_t) g_ascii_strtoll (exp, &error, base); if ((*error == '\0') && (addr >= 0)) { switch (current_goto_type) -- 2.11.4.GIT