Remove lib/getline.c, lib/getdelim.c; refactor src/global to use urj_log()

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1570 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Rutger Hofman 16 years ago
parent 10bb27ff2a
commit 1206f1ddb1

@ -1,5 +1,10 @@
2009-05-05 Rutger Hofman <rfhh>
* src/lib/getline.c, src/lib/getdelim.c: remove because unused
* src/global/parse.c: replace calls to printf() with calls to urj_log() and
urj_error_set()
* include/urjtag/jim.h, include/urjtag/jim/some_cpu.h, src/jim/tap.c,
src/jim/jim_tap.c, src/jim/some_cpu.c, src/jim/intel_28f800b3.c: replace
calls to printf() with calls to urj_log() and urj_error_set()

@ -22,6 +22,8 @@
# Written by Marcel Telka <marcel@telka.sk>, 2003, 2004.
#
# CFLAGS += -Werror
LINT_FLAGS =
LINT_FLAGS += -warnposixheaders
LINT_FLAGS += +boolint

@ -104,7 +104,6 @@ else
fi
fi
AC_CHECK_FUNCS(getline getdelim)
AC_CHECK_FUNCS(swprintf)
AC_CHECK_FUNC(clock_gettime, [], [ AC_CHECK_LIB(rt, clock_gettime) ])

@ -36,7 +36,21 @@
#include "types.h"
/**
* @return:
* 1 on unrecognized command
* otherwise: result from command implementation
* 1 success or library function error
* 0
* -1 command syntax error: wrong number of arguments,
* illegal arguments
*/
int urj_cmd_run (urj_chain_t *chain, char *params[]);
/**
* @return
* malloc'ed value. The caller is responsible for freeing it.
* NULL for malloc failure or end of command list.
*/
char *urj_cmd_find_next (const char *text, int state);
/* @@@@ RFHH candidate to become local in src/cmd/: */
int urj_cmd_params (char *params[]);

@ -29,8 +29,17 @@
#include "types.h"
/**
* @return -1 on failure; see urj_parse_line() otherwise
*/
int urj_parse_file (urj_chain_t *chain, const char *filename);
/**
* @return 1 on failure; urj_cmd_run() otherwise
*/
int urj_parse_line (urj_chain_t *chain, char *line);
/**
* @return see urj_parse_line()
*/
int urj_parse_stream (urj_chain_t *chain, FILE *f);
#endif /* URJ_PARSE_H */

@ -53,10 +53,6 @@
#include <urjtag/parse.h>
#include <urjtag/jtag.h>
#ifndef HAVE_GETLINE
ssize_t urj_lib_getline (char **lineptr, size_t *n, FILE *stream);
#endif
static int urj_interactive = 0;
#define JTAGDIR ".jtag"

@ -43,7 +43,7 @@ cmd_debug_run (urj_chain_t *chain, char *params[])
return -1;
if (urj_cmd_get_number (params[1], &i))
return 1;
return -1;
urj_debug_mode = i;
return 1;

@ -32,6 +32,8 @@
#include <ctype.h>
#include <errno.h>
#include <urjtag/log.h>
#include <urjtag/error.h>
#include <urjtag/chain.h>
#include <urjtag/parse.h>
#include <urjtag/cmd.h>
@ -59,7 +61,7 @@ urj_parse_line (urj_chain_t *chain, char *line)
sline = malloc (l + 1);
if (sline == NULL)
{
printf (_("Out of memory\n"));
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%d) fails", l + 1);
return 1;
}
@ -97,7 +99,8 @@ urj_parse_line (urj_chain_t *chain, char *line)
a = malloc ((tcnt + 1) * sizeof (char *));
if (a == NULL)
{
fprintf (stderr, _("Out of memory\n"));
urj_error_set (URJ_ERROR_OUT_OF_MEMORY, "malloc(%zd) fails",
(tcnt + 1) * sizeof (char *));
return 1;
}
@ -112,10 +115,10 @@ urj_parse_line (urj_chain_t *chain, char *line)
a[tcnt] = NULL;
r = urj_cmd_run (chain, a);
if (urj_debug_mode & 1)
printf ("Return in urj_parse_line r=%d\n", r);
urj_log (URJ_LOG_LEVEL_DEBUG, "Return in urj_parse_line r=%d\n", r);
free (a);
free (sline);
return r;
}
@ -150,9 +153,9 @@ urj_parse_stream (urj_chain_t *chain, FILE *f)
inputline[i] = '\0';
lnr++;
if (clip && !found_comment)
fprintf (stdout,
"Warning: line %d exceeds %d characters, clipped\n", lnr,
(int) sizeof (inputline) - 1);
urj_log (URJ_LOG_LEVEL_WARNINGS,
"line %d exceeds %zd characters, clipped\n", lnr,
sizeof (inputline) - 1);
go = urj_parse_line (chain, inputline);
urj_tap_chain_flush (chain);
}
@ -178,7 +181,7 @@ urj_parse_file (urj_chain_t *chain, const char *filename)
go = urj_parse_stream (chain, f);
fclose (f);
if (urj_debug_mode & 1)
printf ("File Closed gp=%d\n", go);
urj_log (URJ_LOG_LEVEL_DEBUG, "File Closed go=%d\n", go);
return go;
}

@ -40,7 +40,5 @@ libiberty_sources =
endif
libjtaglib_la_SOURCES = \
getdelim.c \
getline.c \
fclock.c \
$(libiberty_sources)

@ -1,95 +0,0 @@
/*
* $Id$
*
* Copyright (C) 2003 ETC s.r.o.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by Marcel Telka <marcel@telka.sk>, 2003.
*
*/
#include <urjtag/sysdep.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#ifndef HAVE_GETDELIM
#define GETDELIM_BUFFER 128
ssize_t
urj_lib_getdelim (char **lineptr, size_t *n, int delimiter, FILE *stream)
{
char *p;
int c;
size_t len = 0;
if (!lineptr || !n || (!*lineptr && *n))
return -1;
/* allocate initial buffer */
if (!*lineptr || !*n)
{
char *np;
np = realloc (*lineptr, GETDELIM_BUFFER);
if (!np)
return -1;
*n = GETDELIM_BUFFER;
*lineptr = np;
}
p = *lineptr;
/* read characters from stream */
while ((c = fgetc (stream)) != EOF)
{
if (len >= *n)
{
char *np = realloc (*lineptr, *n * 2);
if (!np)
return -1;
p = np + (p - *lineptr);
*lineptr = np;
*n *= 2;
}
*p++ = (char) c;
len++;
if (delimiter == c)
break;
}
/* end of file without any bytes read */
if ((c == EOF) && (len == 0))
return -1;
/* trailing '\0' */
if (len >= *n)
{
char *np = realloc (*lineptr, *n + 1);
if (!np)
return -1;
p = np + (p - *lineptr);
*lineptr = np;
*n += 1;
}
*p = '\0';
return len;
}
#endif /* HAVE_GETDELIM */

@ -1,43 +0,0 @@
/*
* $Id$
*
* Copyright (C) 2003 ETC s.r.o.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by Marcel Telka <marcel@telka.sk>, 2003.
*
*/
#include <urjtag/sysdep.h>
#include <stdio.h>
#include <unistd.h>
#ifndef HAVE_GETLINE
#ifndef HAVE_GETDELIM
ssize_t urj_lib_getdelim (char **lineptr, size_t *n, int delimiter,
FILE *stream);
#endif /* HAVE_GETDELIM */
ssize_t
urj_lib_getline (char **lineptr, size_t *n, FILE *stream)
{
return urj_lib_getdelim (lineptr, n, '\n', stream);
}
#endif /* HAVE_GETLINE */

@ -44,8 +44,8 @@ typedef struct
}
jim_cable_params_t;
int
urj_tap_cable_jim_cable_connect (char *params[], urj_cable_t *cable)
static int
jim_cable_connect (char *params[], urj_cable_t *cable)
{
jim_cable_params_t *cable_params;
urj_jim_state_t *s;
@ -80,15 +80,15 @@ urj_tap_cable_jim_cable_connect (char *params[], urj_cable_t *cable)
return 0;
}
void
urj_tap_cable_jim_cable_disconnect (urj_cable_t *cable)
static void
jim_cable_disconnect (urj_cable_t *cable)
{
urj_tap_cable_done (cable);
urj_tap_chain_disconnect (cable->chain);
}
void
urj_tap_cable_jim_cable_free (urj_cable_t *cable)
static void
jim_cable_free (urj_cable_t *cable)
{
if (cable->params != NULL)
{
@ -98,8 +98,8 @@ urj_tap_cable_jim_cable_free (urj_cable_t *cable)
free (cable);
}
void
urj_tap_cable_jim_cable_done (urj_cable_t *cable)
static void
jim_cable_done (urj_cable_t *cable)
{
}
@ -156,11 +156,11 @@ jim_cable_help (const char *cablename)
urj_cable_driver_t urj_tap_cable_jim_driver = {
"JIM",
N_("JTAG target simulator JIM"),
urj_tap_cable_jim_cable_connect,
urj_tap_cable_jim_cable_disconnect,
urj_tap_cable_jim_cable_free,
jim_cable_connect,
jim_cable_disconnect,
jim_cable_free,
jim_cable_init,
urj_tap_cable_jim_cable_done,
jim_cable_done,
urj_tap_cable_generic_set_frequency,
jim_cable_clock,
jim_cable_get_tdo,

Loading…
Cancel
Save