Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5f77b1a

Browse files
committed
Cosmetic cleanups in contrib/isn (doesn't fix the passbyval problem)
1 parent5d2a1a4 commit5f77b1a

File tree

2 files changed

+26
-43
lines changed

2 files changed

+26
-43
lines changed

‎contrib/isn/isn.c

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/contrib/isn/isn.c,v 1.8 2008/01/01 19:45:45 momjian Exp $
10+
* $PostgreSQL: pgsql/contrib/isn/isn.c,v 1.9 2008/11/28 18:04:00 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -17,24 +17,23 @@
1717
#include"fmgr.h"
1818
#include"utils/builtins.h"
1919

20-
PG_MODULE_MAGIC;
21-
2220
#include"isn.h"
23-
2421
#include"EAN13.h"
2522
#include"ISBN.h"
2623
#include"ISMN.h"
2724
#include"ISSN.h"
2825
#include"UPC.h"
2926

27+
PG_MODULE_MAGIC;
28+
3029
#defineMAXEAN13LEN 18
3130

3231
enumisn_type
3332
{
3433
INVALID,ANY,EAN13,ISBN,ISMN,ISSN,UPC
3534
};
3635

37-
staticconstchar*isn_names[]= {"EAN13/UPC/ISxN","EAN13/UPC/ISxN","EAN13","ISBN","ISMN","ISSN","UPC"};
36+
staticconstchar*constisn_names[]= {"EAN13/UPC/ISxN","EAN13/UPC/ISxN","EAN13","ISBN","ISMN","ISSN","UPC"};
3837

3938
staticboolg_weak= false;
4039
staticboolg_initialized= false;
@@ -58,8 +57,7 @@ static bool g_initialized = false;
5857
* Check if the table and its index is correct (just for debugging)
5958
*/
6059
#ifdefISN_DEBUG
61-
static
62-
bool
60+
staticbool
6361
check_table(constchar*(*TABLE)[2],constunsignedTABLE_index[10][2])
6462
{
6563
constchar*aux1,
@@ -139,8 +137,7 @@ check_table(const char *(*TABLE)[2], const unsigned TABLE_index[10][2])
139137
* Formatting and conversion routines.
140138
*---------------------------------------------------------*/
141139

142-
static
143-
unsigned
140+
staticunsigned
144141
dehyphenate(char*bufO,char*bufI)
145142
{
146143
unsignedret=0;
@@ -165,8 +162,7 @@ dehyphenate(char *bufO, char *bufI)
165162
*
166163
* Returns the number of characters acctually hyphenated.
167164
*/
168-
static
169-
unsigned
165+
staticunsigned
170166
hyphenate(char*bufO,char*bufI,constchar*(*TABLE)[2],constunsignedTABLE_index[10][2])
171167
{
172168
unsignedret=0;
@@ -276,8 +272,7 @@ hyphenate(char *bufO, char *bufI, const char *(*TABLE)[2], const unsigned TABLE_
276272
*
277273
* Returns the weight of the number (the check digit value, 0-10)
278274
*/
279-
static
280-
unsigned
275+
staticunsigned
281276
weight_checkdig(char*isn,unsignedsize)
282277
{
283278
unsignedweight=0;
@@ -303,8 +298,7 @@ weight_checkdig(char *isn, unsigned size)
303298
*
304299
* Returns the check digit value (0-9)
305300
*/
306-
static
307-
unsigned
301+
staticunsigned
308302
checkdig(char*num,unsignedsize)
309303
{
310304
unsignedcheck=0,
@@ -341,8 +335,7 @@ checkdig(char *num, unsigned size)
341335
* If errorOK is false, ereport a useful error message if the ean13 is bad.
342336
* If errorOK is true, just return "false" for bad input.
343337
*/
344-
static
345-
bool
338+
staticbool
346339
ean2isn(ean13ean,boolerrorOK,ean13*result,enumisn_typeaccept)
347340
{
348341
enumisn_typetype=INVALID;
@@ -445,8 +438,7 @@ ean2isn(ean13 ean, bool errorOK, ean13 * result, enum isn_type accept)
445438
* ean2UPC/ISxN --- Convert in-place a normalized EAN13 string to the corresponding
446439
*UPC/ISxN string number. Assumes the input string is normalized.
447440
*/
448-
staticinline
449-
void
441+
staticinlinevoid
450442
ean2ISBN(char*isn)
451443
{
452444
char*aux;
@@ -463,17 +455,17 @@ ean2ISBN(char *isn)
463455
else
464456
*aux=check+'0';
465457
}
466-
staticinline
467-
void
458+
459+
staticinlinevoid
468460
ean2ISMN(char*isn)
469461
{
470462
/* the number should come in this format: 979-0-000-00000-0 */
471463
/* Just strip the first part and change the first digit ('0') to 'M' */
472464
hyphenate(isn,isn+4,NULL,NULL);
473465
isn[0]='M';
474466
}
475-
staticinline
476-
void
467+
468+
staticinlinevoid
477469
ean2ISSN(char*isn)
478470
{
479471
unsignedcheck;
@@ -488,8 +480,8 @@ ean2ISSN(char *isn)
488480
isn[8]=check+'0';
489481
isn[9]='\0';
490482
}
491-
staticinline
492-
void
483+
484+
staticinlinevoid
493485
ean2UPC(char*isn)
494486
{
495487
/* the number should come in this format: 000-000000000-0 */
@@ -505,8 +497,7 @@ ean2UPC(char *isn)
505497
*
506498
* Returns the ean13 value of the string.
507499
*/
508-
static
509-
ean13
500+
staticean13
510501
str2ean(constchar*num)
511502
{
512503
ean13ean=0;/* current ean */
@@ -530,8 +521,7 @@ str2ean(const char *num)
530521
* If errorOK is false, ereport a useful error message if the string is bad.
531522
* If errorOK is true, just return "false" for bad input.
532523
*/
533-
static
534-
bool
524+
staticbool
535525
ean2string(ean13ean,boolerrorOK,char*result,boolshortType)
536526
{
537527
constchar*(*TABLE)[2];
@@ -677,8 +667,7 @@ ean2string(ean13 ean, bool errorOK, char *result, bool shortType)
677667
* if the input string ends with '!' it will always be treated as invalid
678668
* (even if the check digit is valid)
679669
*/
680-
static
681-
bool
670+
staticbool
682671
string2ean(constchar*str,boolerrorOK,ean13*result,
683672
enumisn_typeaccept)
684673
{
@@ -1110,7 +1099,6 @@ make_valid(PG_FUNCTION_ARGS)
11101099
PG_RETURN_EAN13(val);
11111100
}
11121101

1113-
#ifdefISN_WEAK_MODE
11141102
/* this function temporarily sets weak input flag
11151103
* (to lose the strictness of check digit acceptance)
11161104
* It's a helper function, not intended to be used!!
@@ -1119,18 +1107,13 @@ PG_FUNCTION_INFO_V1(accept_weak_input);
11191107
Datum
11201108
accept_weak_input(PG_FUNCTION_ARGS)
11211109
{
1110+
#ifdefISN_WEAK_MODE
11221111
g_weak=PG_GETARG_BOOL(0);
1123-
PG_RETURN_BOOL(g_weak);
1124-
}
11251112
#else
1126-
PG_FUNCTION_INFO_V1(accept_weak_input);
1127-
Datum
1128-
accept_weak_input(PG_FUNCTION_ARGS)
1129-
{
11301113
/* function has no effect */
1131-
PG_RETURN_BOOL(false);
1132-
}
11331114
#endif/* ISN_WEAK_MODE */
1115+
PG_RETURN_BOOL(g_weak);
1116+
}
11341117

11351118
PG_FUNCTION_INFO_V1(weak_input_status);
11361119
Datum

‎contrib/isn/isn.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/contrib/isn/isn.h,v 1.5 2008/01/01 19:45:45 momjian Exp $
10+
* $PostgreSQL: pgsql/contrib/isn/isn.h,v 1.6 2008/11/28 18:04:00 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -27,8 +27,8 @@ typedef uint64 ean13;
2727

2828
#defineEAN13_FORMAT UINT64_FORMAT
2929

30-
#definePG_GETARG_EAN13(n) PG_GETARG_INT64((int64)n)
31-
#definePG_RETURN_EAN13(x) PG_RETURN_INT64((int64)x)
30+
#definePG_GETARG_EAN13(n) PG_GETARG_INT64(n)
31+
#definePG_RETURN_EAN13(x) PG_RETURN_INT64(x)
3232

3333
externDatumisn_out(PG_FUNCTION_ARGS);
3434
externDatumean13_out(PG_FUNCTION_ARGS);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp