diff options
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/common.c | 67 | ||||
-rw-r--r-- | libhb/common.h | 2 | ||||
-rw-r--r-- | libhb/ports.c | 66 | ||||
-rw-r--r-- | libhb/ports.h | 1 |
4 files changed, 67 insertions, 69 deletions
diff --git a/libhb/common.c b/libhb/common.c index e501982f8..4e96f72e9 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -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 -} diff --git a/libhb/common.h b/libhb/common.h index 076ecf3db..1cdee684e 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -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]+)" diff --git a/libhb/ports.c b/libhb/ports.c index c7daa43c9..9f5b403cc 100644 --- a/libhb/ports.c +++ b/libhb/ports.c @@ -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 +} diff --git a/libhb/ports.h b/libhb/ports.h index 0a5ad0c12..f6c89b37d 100644 --- a/libhb/ports.h +++ b/libhb/ports.h @@ -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__ |