~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/openbios/libc/extra.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Creation Date: <2003/10/18 13:52:32 samuel>
 
3
 *   Time-stamp: <2003/10/18 13:54:24 samuel>
 
4
 *
 
5
 *      <extra.c>
 
6
 *
 
7
 *      Libc extras
 
8
 *
 
9
 *   Copyright (C) 2003 Samuel Rydh (samuel@ibrium.se)
 
10
 *
 
11
 *   This program is free software; you can redistribute it and/or
 
12
 *   modify it under the terms of the GNU General Public License
 
13
 *   version 2
 
14
 *
 
15
 */
 
16
 
 
17
#include "config.h"
 
18
#include "libc/string.h"
 
19
#include "libc/vsprintf.h"
 
20
#include "libopenbios/bindings.h"
 
21
 
 
22
/* strncpy without 0-pad */
 
23
char *
 
24
strncpy_nopad( char *dest, const char *src, size_t n )
 
25
{
 
26
        int len = MIN( n, strlen(src)+1 );
 
27
        return memcpy( dest, src, len );
 
28
}
 
29
 
 
30
/* printf */
 
31
 
 
32
int forth_printf( const char *fmt, ... )
 
33
{
 
34
        char buf[512];
 
35
        va_list args;
 
36
        int i;
 
37
 
 
38
        va_start(args, fmt);
 
39
        i = vsnprintf(buf, sizeof(buf), fmt, args);
 
40
        va_end(args);
 
41
 
 
42
        PUSH(pointer2cell(buf));
 
43
        PUSH(i);
 
44
        fword("type");
 
45
 
 
46
        return i;
 
47
}
 
48
 
 
49