[FFmpeg-devel] [MPlayer-dev-eng] ctype.h functions on win32
Gianluigi Tiesi
mplayer
Sun Oct 14 06:33:25 CEST 2007
On Sat, Oct 13, 2007 at 10:30:01PM +0200, Reimar D?ffinger wrote:
> Hello,
> On Sat, Oct 13, 2007 at 09:26:23PM +0200, Gianluigi Tiesi wrote:
> > this discussion is going nowhere...
> > I had enough insults, and you provided really
> > no "clean and without bug" code to solve the problem.
>
> And I did not even get the chance to say anything yet...
>
> [...]
> > it's a bug in the ms crt, we don't have the source, we cannot fix it
> > (we? you, I'm not such an holy coder)
>
> Actually we _could_ still fix it (I would not advice is though) and
> actually I think Rich pointed out it actually is not a bug.
>
> > the only way to solve is a workaround and this wouldn't
> > be the first in mplayer
>
> Check if something like
> #define isspace(c) ((c) != EOF && isspace((unsigned char)(c)))
> works.
> It would break libavcodec/eval.c though.
> So maybe better grab libavformat/rtsp.c redir_isspace, change it to
> av_isspace and suggest a patch to ffmpeg putting it into
> libavutil/common.h and use it.
> Well, I admit this probably is a bit overkill...
>
pls try attached patches (splitted mp/lavc/lavf)
I leaved as is all ints that come from fgetc since
it's supposed to be ok
changed chars to unsigned chars where needed
(and also in other similar functions for conformance)
cast to uint8_t/uchar(in input.c uint8_t not defined)
when the source of the value it's not so clear
(at least for me of course :D)
Bye
--
Gianluigi Tiesi <sherpya at netfarm.it>
EDP Project Leader
Netfarm S.r.l. - http://www.netfarm.it/
Free Software: http://oss.netfarm.it/
-------------- next part --------------
Index: vobsub.c
===================================================================
--- vobsub.c (revision 24775)
+++ vobsub.c (working copy)
@@ -225,7 +225,7 @@
/**********************************************************************/
static ssize_t
-vobsub_getline(char **lineptr, size_t *n, rar_stream_t *stream)
+vobsub_getline(unsigned char **lineptr, size_t *n, rar_stream_t *stream)
{
size_t res = 0;
int c;
@@ -235,7 +235,7 @@
*n = 4096;
}
else if (*n == 0) {
- char *tmp = realloc(*lineptr, 4096);
+ unsigned char *tmp = (unsigned char *) realloc(*lineptr, 4096);
if (tmp) {
*lineptr = tmp;
*n = 4096;
@@ -682,11 +682,11 @@
}
static int
-vobsub_parse_id(vobsub_t *vob, const char *line)
+vobsub_parse_id(vobsub_t *vob, const unsigned char *line)
{
// id: xx, index: n
size_t idlen;
- const char *p, *q;
+ const unsigned char *p, *q;
p = line;
while (isspace(*p))
++p;
@@ -710,10 +710,10 @@
}
static int
-vobsub_parse_timestamp(vobsub_t *vob, const char *line)
+vobsub_parse_timestamp(vobsub_t *vob, const unsigned char *line)
{
// timestamp: HH:MM:SS.mmm, filepos: 0nnnnnnnnn
- const char *p;
+ unsigned const char *p;
int h, m, s, ms;
off_t filepos;
while (isspace(*line))
@@ -765,7 +765,7 @@
}
static int
-vobsub_parse_size(vobsub_t *vob, const char *line)
+vobsub_parse_size(vobsub_t *vob, const unsigned char *line)
{
// size: WWWxHHH
char *p;
@@ -782,7 +782,7 @@
}
static int
-vobsub_parse_origin(vobsub_t *vob, const char *line)
+vobsub_parse_origin(vobsub_t *vob, const unsigned char *line)
{
// org: X,Y
char *p;
@@ -799,13 +799,13 @@
}
static int
-vobsub_parse_palette(vobsub_t *vob, const char *line)
+vobsub_parse_palette(vobsub_t *vob, const unsigned char *line)
{
// palette: XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX, XXXXXX
unsigned int n;
n = 0;
while (1) {
- const char *p;
+ const unsigned char *p;
int r, g, b, y, u, v, tmp;
while (isspace(*line))
++line;
@@ -833,7 +833,7 @@
}
static int
-vobsub_parse_custom(vobsub_t *vob, const char *line)
+vobsub_parse_custom(vobsub_t *vob, const unsigned char *line)
{
//custom colors: OFF/ON(0/1)
if ((strncmp("ON", line + 15, 2) == 0)||strncmp("1", line + 15, 1) == 0)
@@ -846,14 +846,14 @@
}
static int
-vobsub_parse_cuspal(vobsub_t *vob, const char *line)
+vobsub_parse_cuspal(vobsub_t *vob, const unsigned char *line)
{
//colors: XXXXXX, XXXXXX, XXXXXX, XXXXXX
unsigned int n;
n = 0;
line += 40;
while(1){
- const char *p;
+ const unsigned char *p;
while (isspace(*line))
++line;
p=line;
@@ -873,7 +873,7 @@
/* don't know how to use tridx */
static int
-vobsub_parse_tridx(const char *line)
+vobsub_parse_tridx(const unsigned char *line)
{
//tridx: XXXX
int tridx;
@@ -883,7 +883,7 @@
}
static int
-vobsub_parse_delay(vobsub_t *vob, const char *line)
+vobsub_parse_delay(vobsub_t *vob, const unsigned char *line)
{
int h, m, s, ms;
int forward = 1;
@@ -909,7 +909,7 @@
}
static int
-vobsub_set_lang(const char *line)
+vobsub_set_lang(const unsigned char *line)
{
if (vobsub_id == -1)
vobsub_id = atoi(line + 8);
@@ -917,9 +917,9 @@
}
static int
-vobsub_parse_forced_subs(vobsub_t *vob, const char *line)
+vobsub_parse_forced_subs(vobsub_t *vob, const unsigned char *line)
{
- const char *p;
+ const unsigned char *p;
p = line;
while (isspace(*p))
@@ -942,7 +942,7 @@
ssize_t line_size;
int res = -1;
size_t line_reserve = 0;
- char *line = NULL;
+ unsigned char *line = NULL;
do {
line_size = vobsub_getline(&line, &line_reserve, fd);
if (line_size < 0) {
Index: stream/udp.c
===================================================================
--- stream/udp.c (revision 24775)
+++ stream/udp.c (working copy)
@@ -69,7 +69,7 @@
return -1;
}
- if (isalpha (url->hostname[0]))
+ if (isalpha ((unsigned char) url->hostname[0]))
{
#ifndef HAVE_WINSOCK2
hp = (struct hostent *) gethostbyname (url->hostname);
@@ -120,7 +120,7 @@
}
#ifdef HAVE_WINSOCK2
- if (isalpha (url->hostname[0]))
+ if (isalpha ((unsigned char) url->hostname[0]))
{
hp = (struct hostent *) gethostbyname (url->hostname);
if (!hp)
Index: stream/stream_dvd.c
===================================================================
--- stream/stream_dvd.c (revision 24775)
+++ stream/stream_dvd.c (working copy)
@@ -156,8 +156,8 @@
stream_opts_fields
};
-int dvd_parse_chapter_range(m_option_t *conf, const char *range) {
- const char *s;
+int dvd_parse_chapter_range(m_option_t *conf, const unsigned char *range) {
+ const unsigned char *s;
char *t;
if (!range)
return M_OPT_MISSING_PARAM;
Index: stream/tv.c
===================================================================
--- stream/tv.c (revision 24775)
+++ stream/tv.c (working copy)
@@ -484,7 +484,7 @@
int channel = 0;
if (tvh->tv_param->channel)
{
- if (isdigit(*tvh->tv_param->channel))
+ if (isdigit((uint8_t) *tvh->tv_param->channel))
/* if tvh->tv_param->channel begins with a digit interpret it as a number */
channel = atoi(tvh->tv_param->channel);
else
Index: codec-cfg.c
===================================================================
--- codec-cfg.c (revision 24775)
+++ codec-cfg.c (working copy)
@@ -323,7 +323,7 @@
static int validate_codec(codecs_t *c, int type)
{
unsigned int i;
- char *tmp_name = c->name;
+ unsigned char *tmp_name = c->name;
for (i = 0; i < strlen(tmp_name) && isalnum(tmp_name[i]); i++)
/* NOTHING */;
@@ -417,8 +417,8 @@
static FILE *fp;
static int line_num = 0;
-static char *line;
-static char *token[MAX_NR_TOKEN];
+static unsigned char *line;
+static unsigned char *token[MAX_NR_TOKEN];
static int read_nextline = 1;
static int get_token(int min, int max)
Index: input/input.c
===================================================================
--- input/input.c (revision 24775)
+++ input/input.c (working copy)
@@ -1353,7 +1353,7 @@
return key_names[i].name;
}
- if(isascii(key)) {
+ if(isascii((unsigned char) key)) {
snprintf(key_str,12,"%c",(char)key);
return key_str;
}
Index: libao2/ao_alsa.c
===================================================================
--- libao2/ao_alsa.c (revision 24775)
+++ libao2/ao_alsa.c (working copy)
@@ -261,7 +261,7 @@
static int try_open_device(const char *device, int open_mode, int try_ac3)
{
int err, len;
- char *ac3_device, *args;
+ unsigned char *ac3_device, *args;
if (try_ac3) {
/* to set the non-audio bit, use AES0=6 */
Index: dvdread/ifo_print.c
===================================================================
--- dvdread/ifo_print.c (revision 24775)
+++ dvdread/ifo_print.c (working copy)
@@ -403,8 +403,8 @@
}
if(attr->type == 1) {
- if(isalpha((int)(attr->lang_code >> 8))
- && isalpha((int)(attr->lang_code & 0xff))) {
+ if(isalpha((unsigned int)(attr->lang_code >> 8))
+ && ((unsigned int)(attr->lang_code & 0xff))) {
printf("%c%c ", attr->lang_code >> 8, attr->lang_code & 0xff);
} else {
printf("%02x%02x ", attr->lang_code >> 8, attr->lang_code & 0xff);
Index: parser-cfg.c
===================================================================
--- parser-cfg.c (revision 24775)
+++ parser-cfg.c (working copy)
@@ -41,10 +41,10 @@
#define MAX_OPT_LEN 1000
#define MAX_PARAM_LEN 1500
FILE *fp;
- char *line;
- char opt[MAX_OPT_LEN + 1];
- char param[MAX_PARAM_LEN + 1];
- char c; /* for the "" and '' check */
+ unsigned char *line;
+ unsigned char opt[MAX_OPT_LEN + 1];
+ unsigned char param[MAX_PARAM_LEN + 1];
+ unsigned char c; /* for the "" and '' check */
int tmp;
int line_num = 0;
int line_pos; /* line pos */
Index: libvo/vo_fbdev.c
===================================================================
--- libvo/vo_fbdev.c (revision 24775)
+++ libvo/vo_fbdev.c (working copy)
@@ -84,8 +84,8 @@
static FILE *fp;
static int line_num = 0;
-static char *line;
-static char *token[MAX_NR_TOKEN];
+static unsigned char *line;
+static unsigned char *token[MAX_NR_TOKEN];
static int get_token(int num)
{
Index: libvo/gl_common.c
===================================================================
--- libvo/gl_common.c (revision 24775)
+++ libvo/gl_common.c (working copy)
@@ -389,7 +389,7 @@
*/
int glCreatePPMTex(GLenum target, GLenum fmt, GLint filter,
FILE *f, int *width, int *height, int *maxval) {
- unsigned w, h, m, val, bpp;
+ unsigned w, h, m, bpp;
char *data;
ppm_skip(f);
if (fgetc(f) != 'P' || fgetc(f) != '6')
@@ -403,8 +403,7 @@
ppm_skip(f);
if (fscanf(f, "%u", &m) != 1)
return 0;
- val = fgetc(f);
- if (!isspace(val))
+ if (!isspace(fgetc(f)))
return 0;
if (w > MAXDIM || h > MAXDIM)
return 0;
Index: libmenu/menu_console.c
===================================================================
--- libmenu/menu_console.c (revision 24775)
+++ libmenu/menu_console.c (working copy)
@@ -444,7 +444,7 @@
return;
}
- if(isascii(c)) {
+ if(isascii((uint8_t) c)) {
int l = strlen(mpriv->cur_history->buffer);
if(l >= mpriv->cur_history->size) {
mpriv->cur_history->size += 255;
Index: subreader.c
===================================================================
--- subreader.c (revision 24775)
+++ subreader.c (working copy)
@@ -67,12 +67,12 @@
unsigned long previous_sub_end;
#endif
-static int eol(char p) {
+static int eol(unsigned char p) {
return (p=='\r' || p=='\n' || p=='\0');
}
/* Remove leading and trailing space */
-static void trail_space(char *s) {
+static void trail_space(unsigned char *s) {
int i = 0;
while (isspace(s[i])) ++i;
if (i) strcpy(s, s + i);
@@ -625,8 +625,8 @@
* by set, based on code by szabi (dunnowhat sub format ;-)
*/
static subtitle *sub_read_line_pjs(stream_t *st,subtitle *current) {
- char line[LINE_LEN+1];
- char text[LINE_LEN+1], *s, *d;
+ unsigned char line[LINE_LEN+1];
+ unsigned char text[LINE_LEN+1], *s, *d;
if (!stream_read_line (st, line, LINE_LEN))
return NULL;
@@ -666,7 +666,7 @@
char line[LINE_LEN+1];
float a,b;
int num=0;
- char *p, *q;
+ unsigned char *p, *q;
do
{
@@ -818,7 +818,7 @@
static subtitle *sub_read_line_jacosub(stream_t* st, subtitle * current)
{
- char line1[LINE_LEN], line2[LINE_LEN], directive[LINE_LEN], *p, *q;
+ unsigned char line1[LINE_LEN], line2[LINE_LEN], directive[LINE_LEN], *p, *q;
unsigned a1, a2, a3, a4, b1, b2, b3, b4, comment = 0;
static unsigned jacoTimeres = 30;
static int jacoShift = 0;
@@ -1728,7 +1728,7 @@
#endif
-static void strcpy_trim(char *d, char *s)
+static void strcpy_trim(unsigned char *d, unsigned char *s)
{
// skip leading whitespace
while (*s && !isalnum(*s)) {
@@ -1778,7 +1778,7 @@
}
}
-static int whiteonly(char *s)
+static int whiteonly(unsigned char *s)
{
while (*s) {
if (isalnum(*s)) return 0;
Index: libmpdemux/mf.c
===================================================================
--- libmpdemux/mf.c (revision 24775)
+++ libmpdemux/mf.c (working copy)
@@ -49,7 +49,7 @@
while ( fgets( fname,255,lst_f ) )
{
/* remove spaces from end of fname */
- char *t=fname + strlen( fname ) - 1;
+ unsigned char *t=fname + strlen( fname ) - 1;
while ( t > fname && isspace( *t ) ) *(t--)=0;
if ( stat( fname,&fs ) )
{
Index: libmpdemux/demux_mkv.c
===================================================================
--- libmpdemux/demux_mkv.c (revision 24775)
+++ libmpdemux/demux_mkv.c (working copy)
@@ -303,7 +303,7 @@
}
static int
-vobsub_parse_palette (sh_sub_t *sh, const char *start)
+vobsub_parse_palette (sh_sub_t *sh, const unsigned char *start)
{
int i, r, g, b, y, u, v, tmp;
@@ -345,7 +345,7 @@
}
static int
-vobsub_parse_custom_colors (sh_sub_t *sh, const char *start)
+vobsub_parse_custom_colors (sh_sub_t *sh, const unsigned char *start)
{
int use_custom_colors, i;
@@ -387,7 +387,7 @@
}
static int
-vobsub_parse_forced_subs (sh_sub_t *sh, const char *start)
+vobsub_parse_forced_subs (sh_sub_t *sh, const unsigned char *start)
{
start += 12;
while (isspace(*start))
Index: drivers/mga_vid.c
===================================================================
--- drivers/mga_vid.c (revision 24775)
+++ drivers/mga_vid.c (working copy)
@@ -121,7 +121,7 @@
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
#include <linux/ctype.h>
-static unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
+static unsigned long simple_strtoul(const unsigned char *cp,char **endp,unsigned int base)
{
unsigned long result = 0,value;
-------------- next part --------------
Index: eval.c
===================================================================
--- eval.c (revision 10728)
+++ eval.c (working copy)
@@ -376,7 +376,7 @@
}
}
-AVEvalExpr * ff_parse(char *s, const char **const_name,
+AVEvalExpr * ff_parse(unsigned char *s, const char **const_name,
double (**func1)(void *, double), const char **func1_name,
double (**func2)(void *, double, double), char **func2_name,
char **error){
@@ -413,7 +413,7 @@
return eval_expr(&p, e);
}
-double ff_eval2(char *s, double *const_value, const char **const_name,
+double ff_eval2(unsigned char *s, double *const_value, const char **const_name,
double (**func1)(void *, double), const char **func1_name,
double (**func2)(void *, double, double), char **func2_name,
void *opaque, char **error){
@@ -426,7 +426,7 @@
}
#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
-attribute_deprecated double ff_eval(char *s, double *const_value, const char **const_name,
+attribute_deprecated double ff_eval(unsigned char *s, double *const_value, const char **const_name,
double (**func1)(void *, double), const char **func1_name,
double (**func2)(void *, double, double), char **func2_name,
void *opaque){
Index: eval.h
===================================================================
--- eval.h (revision 10728)
+++ eval.h (working copy)
@@ -32,7 +32,7 @@
/**
* @deprecated Use ff_eval2 instead
*/
-double ff_eval(char *s, double *const_value, const char **const_name,
+double ff_eval(unsigned char *s, double *const_value, const char **const_name,
double (**func1)(void *, double), const char **func1_name,
double (**func2)(void *, double, double), char **func2_name,
void *opaque);
@@ -52,7 +52,7 @@
* @param opaque a pointer which will be passed to all functions from func1 and func2
* @return the value of the expression
*/
-double ff_eval2(char *s, double *const_value, const char **const_name,
+double ff_eval2(unsigned char *s, double *const_value, const char **const_name,
double (**func1)(void *, double), const char **func1_name,
double (**func2)(void *, double, double), char **func2_name,
void *opaque, char **error);
@@ -71,7 +71,7 @@
* @return AVEvalExpr which must be freed with ff_eval_free by the user when it is not needed anymore
* NULL if anything went wrong
*/
-AVEvalExpr * ff_parse(char *s, const char **const_name,
+AVEvalExpr * ff_parse(unsigned char *s, const char **const_name,
double (**func1)(void *, double), const char **func1_name,
double (**func2)(void *, double, double), char **func2_name,
char **error);
-------------- next part --------------
Index: avformat.h
===================================================================
--- avformat.h (revision 10728)
+++ avformat.h (working copy)
@@ -863,7 +863,7 @@
* @number frame number
* @return 0 if OK, -1 if format error.
*/
-int av_get_frame_filename(char *buf, int buf_size,
+int av_get_frame_filename(unsigned char *buf, int buf_size,
const char *path, int number);
/**
Index: utils.c
===================================================================
--- utils.c (revision 10728)
+++ utils.c (working copy)
@@ -2586,7 +2586,7 @@
int64_t parse_date(const char *datestr, int duration)
{
- const char *p;
+ const unsigned char *p;
int64_t t;
struct tm dt;
int i;
@@ -2598,7 +2598,7 @@
"%H:%M:%S",
"%H%M%S",
};
- const char *q;
+ const unsigned char *q;
int is_utc, len;
char lastch;
int negative = 0;
@@ -2739,11 +2739,11 @@
return 0;
}
-int av_get_frame_filename(char *buf, int buf_size,
+int av_get_frame_filename(unsigned char *buf, int buf_size,
const char *path, int number)
{
- const char *p;
- char *q, buf1[20], c;
+ const unsigned char *p;
+ unsigned char *q, buf1[20], c;
int nd, len, percentd_found;
q = buf;
Index: cutils.c
===================================================================
--- cutils.c (revision 10728)
+++ cutils.c (working copy)
@@ -105,7 +105,7 @@
val = 0;
for(i = 0; i < len_max; i++) {
c = *p;
- if (!isdigit(c))
+ if (!isdigit((uint8_t) c))
break;
val = (val * 10) + c - '0';
p++;
Index: http.c
===================================================================
--- http.c (revision 10728)
+++ http.c (working copy)
@@ -150,11 +150,11 @@
return *s->buf_ptr++;
}
-static int process_line(URLContext *h, char *line, int line_count,
+static int process_line(URLContext *h, unsigned char *line, int line_count,
int *new_location)
{
HTTPContext *s = h->priv_data;
- char *tag, *p;
+ unsigned char *tag, *p;
/* end of header */
if (line[0] == '\0')
Index: avio.c
===================================================================
--- avio.c (revision 10728)
+++ avio.c (working copy)
@@ -40,7 +40,7 @@
{
URLContext *uc;
URLProtocol *up;
- const char *p;
+ const unsigned char *p;
char proto_str[128], *q;
int err;
More information about the ffmpeg-devel
mailing list