]> granicus.if.org Git - handbrake/commitdiff
ports: move hb_getline to ports.c where it belongs
authorJohn Stebbins <jstebbins.hb@gmail.com>
Sun, 6 Jan 2019 17:57:49 +0000 (10:57 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Mon, 14 Jan 2019 21:36:08 +0000 (13:36 -0800)
libhb/common.c
libhb/common.h
libhb/ports.c
libhb/ports.h

index e501982f838e5732f01a8970e78b70eee5edd3f9..4e96f72e96a07a75bed01048a3b28be7b6f9bdd1 100644 (file)
@@ -5704,70 +5704,3 @@ void hb_chapter_dequeue(hb_chapter_queue_t *q, hb_buffer_t *buf)
         free(item);
     }
 }
-
-size_t hb_getline(char ** lineptr, size_t * n, FILE * fp)
-{
-#ifdef SYS_MINGW
-    char   * bufptr = NULL;
-    char   * p      = bufptr;
-    size_t   size;
-    int      c;
-
-    if (lineptr == NULL)
-    {
-        return -1;
-    }
-    if (fp == NULL)
-    {
-        return -1;
-    }
-    if (n == NULL)
-    {
-        return -1;
-    }
-    bufptr = *lineptr;
-    size   = *n;
-
-    c = fgetc(fp);
-    if (c == EOF)
-    {
-        return -1;
-    }
-    if (bufptr == NULL)
-    {
-        bufptr = malloc(128);
-        if (bufptr == NULL)
-        {
-            return -1;
-        }
-        size = 128;
-    }
-    p = bufptr;
-    while (c != EOF)
-    {
-        if ((p - bufptr) > (size - 1))
-        {
-            size = size + 128;
-            bufptr = realloc(bufptr, size);
-            if (bufptr == NULL)
-            {
-                return -1;
-            }
-        }
-        *p++ = c;
-        if (c == '\n')
-        {
-            break;
-        }
-        c = fgetc(fp);
-    }
-
-    *p++ = '\0';
-    *lineptr = bufptr;
-    *n = size;
-
-    return p - bufptr - 1;
-#else
-    return getline(lineptr, n, fp);
-#endif
-}
index 076ecf3dbb5ed8c1c5c73e95ef1d03dde3f00bf5..1cdee684e68776ecdc44a994a9bf31847056e549 100644 (file)
@@ -1387,8 +1387,6 @@ const char * hb_x264_encopt_name( const char * name );
 const char * hb_x265_encopt_name( const char * name );
 #endif
 
-size_t hb_getline(char **lineptr, size_t *n, FILE *fp);
-
 #define HB_NEG_FLOAT_REG "(([-])?(([0-9]+([.,][0-9]+)?)|([.,][0-9]+))"
 #define HB_FLOAT_REG     "(([0-9]+([.,][0-9]+)?)|([.,][0-9]+))"
 #define HB_NEG_INT_REG   "(([-]?[0-9]+)"
index c7daa43c9b78759c03a134f9ad66e962bc14eaf8..9f5b403cc37ff5d3fb4756ec2e30d2dff3db1116 100644 (file)
@@ -1405,3 +1405,69 @@ int hb_dlclose(void *h)
 #endif
 }
 
+size_t hb_getline(char ** lineptr, size_t * n, FILE * fp)
+{
+#ifdef SYS_MINGW
+    char   * bufptr = NULL;
+    char   * p      = bufptr;
+    size_t   size;
+    int      c;
+
+    if (lineptr == NULL)
+    {
+        return -1;
+    }
+    if (fp == NULL)
+    {
+        return -1;
+    }
+    if (n == NULL)
+    {
+        return -1;
+    }
+    bufptr = *lineptr;
+    size   = *n;
+
+    c = fgetc(fp);
+    if (c == EOF)
+    {
+        return -1;
+    }
+    if (bufptr == NULL)
+    {
+        bufptr = malloc(128);
+        if (bufptr == NULL)
+        {
+            return -1;
+        }
+        size = 128;
+    }
+    p = bufptr;
+    while (c != EOF)
+    {
+        if ((p - bufptr) > (size - 1))
+        {
+            size = size + 128;
+            bufptr = realloc(bufptr, size);
+            if (bufptr == NULL)
+            {
+                return -1;
+            }
+        }
+        *p++ = c;
+        if (c == '\n')
+        {
+            break;
+        }
+        c = fgetc(fp);
+    }
+
+    *p++ = '\0';
+    *lineptr = bufptr;
+    *n = size;
+
+    return p - bufptr - 1;
+#else
+    return getline(lineptr, n, fp);
+#endif
+}
index 0a5ad0c12da4e3aa6493d53e80084a6d93eac0a9..f6c89b37d38693ffdafe74ba8d138bef764cb865 100644 (file)
@@ -88,6 +88,7 @@ char * hb_strr_dir_sep(const char *path);
  ***********************************************************************/
 char * hb_get_temporary_directory(void);
 char * hb_get_temporary_filename( char *fmt, ... );
+size_t hb_getline(char **lineptr, size_t *n, FILE *fp);
 
 #ifdef __LIBHB__