License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
#include <stdlib.h>
#include <stdio.h>
unsigned int width, int left_just, char pad)
{
int res = 0;
- int i;
- int to_pad = width - len;
+ size_t i;
+ size_t to_pad = width > len ? width - len : 0;
/* If not left justified, pad left */
- for(i = 0; !left_just && i < to_pad; ++i)
+ for (i = 0; !left_just && i < to_pad; ++i)
res += lc_appendable_chadd(app, pad);
/* Send the visible portion of the string to the output. */
res += lc_appendable_snadd(app, str, len);
/* If left justified, pad right. */
- for(i = 0; left_just && i < to_pad; ++i)
+ for (i = 0; left_just && i < to_pad; ++i)
res += lc_appendable_chadd(app, pad);
return res;
static int file_snadd(lc_appendable_t *obj, const char *str, size_t n)
{
obj->written += n;
- fwrite(str, sizeof(char), n, obj->obj);
+ fwrite(str, sizeof(char), n, (FILE*)obj->obj);
return n;
}
static int file_chadd(lc_appendable_t *obj, int ch)
{
- fputc(ch, obj->obj);
+ fputc(ch, (FILE*)obj->obj);
obj->written++;
return 1;
}
static void str_init(lc_appendable_t *obj)
{
- strncpy(obj->obj, "", obj->limit);
+ strncpy((char*)obj->obj, "", obj->limit);
}
static int str_snadd(lc_appendable_t *obj, const char *str, size_t n)
{
size_t to_write = LC_MIN(obj->limit - obj->written - 1, n);
- char *tgt = obj->obj;
+ char *tgt = (char*)obj->obj;
strncpy(tgt + obj->written, str, to_write);
obj->written += to_write;
return to_write;
static int str_chadd(lc_appendable_t *obj, int ch)
{
- if(obj->limit - obj->written > 1) {
- char *tgt = obj->obj;
+ if (obj->limit - obj->written > 1) {
+ char *tgt = (char*)obj->obj;
tgt[obj->written++] = (char) ch;
return 1;
}
static void str_finish(lc_appendable_t *obj)
{
- char *str = obj->obj;
+ char *str = (char*)obj->obj;
str[obj->written] = '\0';
}
static int obst_snadd(lc_appendable_t *obj, const char *str, size_t n)
{
- struct obstack *obst = obj->obj;
+ struct obstack *obst = (struct obstack*)obj->obj;
obj->written += n;
obstack_grow(obst, str, n);
return n;
static int obst_chadd(lc_appendable_t *obj, int ch)
{
- struct obstack *obst = obj->obj;
+ struct obstack *obst = (struct obstack*)obj->obj;
obstack_1grow(obst, (char) ch);
obj->written++;
return 1;