Browse Source

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 <aborodin@vmail.ru>
Andrew Borodin 12 years ago
parent
commit
17cadc50ec
6 changed files with 9 additions and 18 deletions
  1. 0 1
      configure.ac
  2. 1 1
      lib/util.c
  3. 1 5
      lib/vfs/parse_ls_vga.c
  4. 4 4
      m4.include/ac-glib.m4
  5. 2 6
      src/vfs/fish/fish.c
  6. 1 1
      src/viewer/dialogs.c

+ 0 - 1
configure.ac

@@ -226,7 +226,6 @@ dnl Check for functions
 dnl ############################################################################
 
 AC_CHECK_FUNCS([\
-	atoll \
 	isascii \
 	statfs sysconf \
 	tcgetattr tcsetattr \

+ 1 - 1
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++)
                     {

+ 1 - 5
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

+ 4 - 4
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
 
 ])

+ 2 - 6
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);

+ 1 - 1
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)