Postfix3.3.1
総合概要
データ構造
ファイル
ファイル一覧
大域各種
postfix-3.3.1
src
util
line_number.c
[詳解]
1
/*++
2
/* NAME
3
/* line_number 3
4
/* SUMMARY
5
/* line number utilities
6
/* SYNOPSIS
7
/* #include <line_number.h>
8
/*
9
/* char *format_line_number(result, first, last)
10
/* VSTRING *buffer;
11
/* ssize_t first;
12
/* ssize_t lastl
13
/* DESCRIPTION
14
/* format_line_number() formats a line number or number range.
15
/* The output is <first-number>-<last-number> when the numbers
16
/* differ, <first-number> when the numbers are identical.
17
/* .IP result
18
/* Result buffer, or null-pointer. In the latter case the
19
/* result is stored in a static buffer that is overwritten
20
/* with subsequent calls. The function result value is a
21
/* pointer into the result buffer.
22
/* .IP first
23
/* First line number.
24
/* .IP last
25
/* Last line number.
26
/* LICENSE
27
/* .ad
28
/* .fi
29
/* The Secure Mailer license must be distributed with this software.
30
/* AUTHOR(S)
31
/* Wietse Venema
32
/* IBM T.J. Watson Research
33
/* P.O. Box 704
34
/* Yorktown Heights, NY 10598, USA
35
/*--*/
36
37
/*
38
* System library.
39
*/
40
#include <
sys_defs.h
>
41
42
/*
43
* Utility library.
44
*/
45
#include <
vstring.h
>
46
#include <
line_number.h
>
47
48
/* format_line_number - pretty-print line number or number range */
49
50
char
*
format_line_number
(
VSTRING
*result, ssize_t first, ssize_t last)
51
{
52
static
VSTRING
*buf;
53
54
/*
55
* Your buffer or mine?
56
*/
57
if
(result == 0) {
58
if
(buf == 0)
59
buf =
vstring_alloc
(10);
60
result = buf;
61
}
62
63
/*
64
* Print a range only when the numbers differ.
65
*/
66
vstring_sprintf
(result,
"%ld"
, (
long
) first);
67
if
(first != last)
68
vstring_sprintf_append
(result,
"-%ld"
, (
long
) last);
69
70
return
(
vstring_str
(result));
71
}
vstring_str
#define vstring_str(vp)
Definition:
vstring.h:71
format_line_number
char * format_line_number(VSTRING *result, ssize_t first, ssize_t last)
Definition:
line_number.c:50
vstring_sprintf_append
VSTRING * vstring_sprintf_append(VSTRING *vp, const char *format,...)
Definition:
vstring.c:624
vstring_alloc
VSTRING * vstring_alloc(ssize_t len)
Definition:
vstring.c:353
VSTRING
Definition:
vstring.h:29
vstring.h
vstring_sprintf
VSTRING * vstring_sprintf(VSTRING *vp, const char *format,...)
Definition:
vstring.c:602
sys_defs.h
line_number.h
2018年11月10日(土) 18時59分57秒作成 - Postfix3.3.1 / 構成:
1.8.9.1