forked from adesutherland/CMS-370-BREXX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
center.c
45 lines (40 loc) · 984 Bytes
/
center.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* $Id: center.c,v 1.4 2008/07/15 07:40:54 bnv Exp $
* $Log: center.c,v $
* Revision 1.4 2008/07/15 07:40:54 bnv
* #include changed from <> to ""
*
* Revision 1.3 2002/06/11 12:37:15 bnv
* Added: CDECL
*
* Revision 1.2 2001/06/25 18:49:48 bnv
* Header changed to Id
*
* Revision 1.1 1998/07/02 17:17:00 bnv
* Initial revision
*
*/
#include <string.h>
#include "lstring.h"
/* ------------------ Lcenter ----------------- */
void __CDECL
Lcenter(const PLstr to, const PLstr from, const long length, const char pad) {
long i, a;
if (length <= 0) {
LZEROSTR(*to);
return;
}
L2STR(to);
L2STR(from);
i = length - LLEN(*from);
if (!i) Lstrcpy(to, from);
else if (i < 0) {
i = -i;
a = i / 2;
_Lsubstr(to, from, (size_t) a + 1, (size_t) length);
} else {
a = i / 2;
Lstrset(to, length, pad);
MEMCPY(LSTR(*to) + a, LSTR(*from), LLEN(*from));
}
} /* Lcenter */