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

Commitd65bea2

Browse files
committed
Move psql's print.c and mbprint.c into src/fe_utils.
Just turning the crank ...
1 parenta376960 commitd65bea2

File tree

21 files changed

+108
-94
lines changed

21 files changed

+108
-94
lines changed

‎src/bin/psql/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS)
2222
LDFLAGS += -L$(top_builddir)/src/fe_utils -lpgfeutils
2323

2424
OBJS=command.o common.o help.o input.o stringutils.o mainloop.o copy.o\
25-
startup.o prompt.o variables.o large_obj.oprint.odescribe.o\
26-
tab-complete.ombprint.o\
25+
startup.o prompt.o variables.o large_obj.o describe.o\
26+
tab-complete.o\
2727
sql_help.o psqlscan.o psqlscanslash.o\
2828
$(WIN32RES)
2929

‎src/bin/psql/command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include"input.h"
4545
#include"large_obj.h"
4646
#include"mainloop.h"
47-
#include"print.h"
47+
#include"fe_utils/print.h"
4848
#include"psqlscanslash.h"
4949
#include"settings.h"
5050
#include"variables.h"

‎src/bin/psql/command.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#ifndefCOMMAND_H
99
#defineCOMMAND_H
1010

11-
#include"print.h"
11+
#include"fe_utils/print.h"
1212
#include"psqlscan.h"
1313

1414

‎src/bin/psql/common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include"settings.h"
2424
#include"command.h"
2525
#include"copy.h"
26-
#include"mbprint.h"
26+
#include"fe_utils/mbprint.h"
2727

2828

2929
staticboolExecQueryUsingCursor(constchar*query,double*elapsed_msec);

‎src/bin/psql/common.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include<setjmp.h>
1212

1313
#include"libpq-fe.h"
14-
#include"print.h"
14+
#include"fe_utils/print.h"
1515

1616
#defineatooid(x) ((Oid) strtoul((x), NULL, 10))
1717

@@ -28,10 +28,6 @@ extern volatile bool sigint_interrupt_enabled;
2828

2929
externsigjmp_bufsigint_interrupt_jmp;
3030

31-
externvolatileboolcancel_pressed;
32-
33-
/* Note: cancel_pressed is defined in print.c, see that file for reasons */
34-
3531
externvoidsetup_cancel_handler(void);
3632

3733
externvoidSetCancelConn(void);

‎src/bin/psql/describe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
#include"common.h"
2121
#include"describe.h"
22-
#include"mbprint.h"
23-
#include"print.h"
22+
#include"fe_utils/mbprint.h"
23+
#include"fe_utils/print.h"
2424
#include"settings.h"
2525
#include"variables.h"
2626

‎src/bin/psql/mbprint.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎src/bin/psql/nls.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
CATALOG_NAME = psql
33
AVAIL_LANGUAGES = cs de es fr it ja pl pt_BR ru zh_CN zh_TW
44
GETTEXT_FILES = command.c common.c copy.c help.c input.c large_obj.c\
5-
mainloop.cprint.cpsqlscan.c psqlscanslash.c startup.c\
5+
mainloop.c psqlscan.c psqlscanslash.c startup.c\
66
describe.c sql_help.h sql_help.c\
77
tab-complete.c variables.c\
8+
../../fe_utils/print.c\
89
../../common/exec.c ../../common/fe_memutils.c ../../common/username.c\
910
../../common/wait_error.c
1011
GETTEXT_TRIGGERS = N_ psql_error simple_prompt

‎src/bin/psql/settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
#include"variables.h"
13-
#include"print.h"
13+
#include"fe_utils/print.h"
1414

1515
#defineDEFAULT_FIELD_SEP "|"
1616
#defineDEFAULT_RECORD_SEP "\n"

‎src/bin/psql/startup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include"help.h"
2727
#include"input.h"
2828
#include"mainloop.h"
29-
#include"print.h"
29+
#include"fe_utils/print.h"
3030
#include"settings.h"
3131

3232

‎src/bin/scripts/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@
99
/vacuumdb
1010
/pg_isready
1111

12-
/mbprint.c
13-
/print.c
14-
1512
/tmp_check/

‎src/bin/scripts/Makefile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ include $(top_builddir)/src/Makefile.global
1818

1919
PROGRAMS = createdb createlang createuser dropdb droplang dropuser clusterdb vacuumdb reindexdb pg_isready
2020

21-
overrideCPPFLAGS := -I$(top_srcdir)/src/bin/psql -I$(libpq_srcdir)$(CPPFLAGS)
21+
overrideCPPFLAGS := -I$(libpq_srcdir)$(CPPFLAGS)
2222
LDFLAGS += -L$(top_builddir)/src/fe_utils -lpgfeutils
2323

2424
all:$(PROGRAMS)
@@ -27,19 +27,16 @@ all: $(PROGRAMS)
2727
$(CC)$(CFLAGS)$^$(libpq_pgport)$(LDFLAGS)$(LDFLAGS_EX)$(LIBS) -o$@$(X)
2828

2929
createdb: createdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
30-
createlang: createlang.o common.oprint.o mbprint.o| submake-libpq submake-libpgport
30+
createlang: createlang.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
3131
createuser: createuser.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
3232
dropdb: dropdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
33-
droplang: droplang.o common.oprint.o mbprint.o| submake-libpq submake-libpgport
33+
droplang: droplang.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
3434
dropuser: dropuser.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
3535
clusterdb: clusterdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
3636
vacuumdb: vacuumdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
3737
reindexdb: reindexdb.o common.o | submake-libpq submake-libpgport submake-libpgfeutils
3838
pg_isready: pg_isready.o common.o | submake-libpq submake-libpgport
3939

40-
print.cmbprint.c :% :$(top_srcdir)/src/bin/psql/%
41-
rm -f$@&&$(LN_S)$<.
42-
4340
install: all installdirs
4441
$(INSTALL_PROGRAM) createdb$(X)'$(DESTDIR)$(bindir)'/createdb$(X)
4542
$(INSTALL_PROGRAM) dropdb$(X)'$(DESTDIR)$(bindir)'/dropdb$(X)
@@ -60,8 +57,7 @@ uninstall:
6057

6158
cleandistcleanmaintainer-clean:
6259
rm -f$(addsuffix$(X),$(PROGRAMS))$(addsuffix .o,$(PROGRAMS))
63-
rm -f common.o print.o mbprint.o$(WIN32RES)
64-
rm -f print.c mbprint.c
60+
rm -f common.o$(WIN32RES)
6561
rm -rf tmp_check
6662

6763
check:

‎src/bin/scripts/createlang.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include"postgres_fe.h"
1313

1414
#include"common.h"
15-
#include"print.h"
15+
#include"fe_utils/print.h"
1616

1717
staticvoidhelp(constchar*progname);
1818

‎src/bin/scripts/droplang.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include"postgres_fe.h"
1313

1414
#include"common.h"
15-
#include"print.h"
15+
#include"fe_utils/print.h"
1616

1717
#defineatooid(x) ((Oid) strtoul((x), NULL, 10))
1818

‎src/bin/scripts/nls.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ GETTEXT_FILES = createdb.c createlang.c createuser.c \
66
clusterdb.c vacuumdb.c reindexdb.c\
77
pg_isready.c\
88
common.c\
9+
../../fe_utils/print.c\
910
../../common/fe_memutils.c ../../common/username.c
1011
GETTEXT_TRIGGERS = simple_prompt yesno_prompt

‎src/fe_utils/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ include $(top_builddir)/src/Makefile.global
1717

1818
overrideCPPFLAGS := -DFRONTEND -I$(libpq_srcdir)$(CPPFLAGS)
1919

20-
OBJS = simple_list.o string_utils.o
20+
OBJS =mbprint.o print.osimple_list.o string_utils.o
2121

2222
all: libpgfeutils.a
2323

‎src/bin/psql/mbprint.crenamed to‎src/fe_utils/mbprint.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
/*
2-
* psql - the PostgreSQL interactive terminal
1+
/*-------------------------------------------------------------------------
2+
*
3+
* Multibyte character printing support for frontend code
4+
*
35
*
4-
* Copyright (c) 2000-2016, PostgreSQL Global Development Group
6+
* Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
7+
* Portions Copyright (c) 1994, Regents of the University of California
58
*
6-
* src/bin/psql/mbprint.c
9+
* src/fe_utils/mbprint.c
710
*
8-
* XXX this file does not really belong in psql/. Perhaps move to libpq?
9-
* It also seems that the mbvalidate function is redundant with existing
10-
* functionality.
11+
*-------------------------------------------------------------------------
1112
*/
12-
1313
#include"postgres_fe.h"
14-
#include"mbprint.h"
15-
#ifndefPGSCRIPTS
16-
#include"settings.h"
17-
#endif
14+
15+
#include"fe_utils/mbprint.h"
16+
17+
#include"libpq-fe.h"
18+
1819

1920
/*
2021
* To avoid version-skew problems, this file must not use declarations
@@ -381,6 +382,12 @@ pg_wcsformat(const unsigned char *pwcs, size_t len, int encoding,
381382
(lines+1)->ptr=NULL;/* terminate line array */
382383
}
383384

385+
386+
/*
387+
* Encoding validation: delete any unvalidatable characters from the string
388+
*
389+
* This seems redundant with existing functionality elsewhere?
390+
*/
384391
unsignedchar*
385392
mbvalidate(unsignedchar*pwcs,intencoding)
386393
{

‎src/bin/psql/print.crenamed to‎src/fe_utils/print.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
/*
2-
* psql - the PostgreSQL interactive terminal
1+
/*-------------------------------------------------------------------------
2+
*
3+
* Query-result printing support for frontend code
4+
*
5+
* This file used to be part of psql, but now it's separated out to allow
6+
* other frontend programs to use it. Because the printing code needs
7+
* access to the cancel_pressed flag as well as SIGPIPE trapping and
8+
* pager open/close functions, all that stuff came with it.
9+
*
10+
*
11+
* Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
12+
* Portions Copyright (c) 1994, Regents of the University of California
313
*
4-
*Copyright (c) 2000-2016, PostgreSQL Global Development Group
14+
*src/fe_utils/print.c
515
*
6-
* src/bin/psql/print.c
16+
*-------------------------------------------------------------------------
717
*/
818
#include"postgres_fe.h"
919

1020
#include<limits.h>
21+
#include<locale.h>
1122
#include<math.h>
1223
#include<signal.h>
1324
#include<unistd.h>
@@ -20,32 +31,23 @@
2031
#include<termios.h>
2132
#endif
2233

23-
#include<locale.h>
34+
#include"fe_utils/print.h"
2435

2536
#include"catalog/pg_type.h"
37+
#include"fe_utils/mbprint.h"
2638

27-
#include"common.h"
28-
#include"mbprint.h"
29-
#include"print.h"
3039

3140
/*
32-
* We define the cancel_pressed flag in this file, rather than common.c where
33-
* it naturally belongs, because this file is also used by non-psql programs
34-
* (see the bin/scripts/ directory). In those programs cancel_pressed will
35-
* never become set and will have no effect.
41+
* If the calling program doesn't have any mechanism for setting
42+
* cancel_pressed, it will have no effect.
3643
*
3744
* Note: print.c's general strategy for when to check cancel_pressed is to do
3845
* so at completion of each row of output.
3946
*/
4047
volatileboolcancel_pressed= false;
4148

42-
/*
43-
* Likewise, the sigpipe_trap and pager open/close functions are here rather
44-
* than in common.c so that this file can be used by non-psql programs.
45-
*/
4649
staticboolalways_ignore_sigpipe= false;
4750

48-
4951
/* info for locale-aware numeric formatting; set up by setDecimalLocale() */
5052
staticchar*decimal_point;
5153
staticintgroupdigits;
@@ -139,7 +141,7 @@ typedef struct unicodeStyleFormat
139141
boolwrap_right_border;
140142
}unicodeStyleFormat;
141143

142-
constunicodeStyleFormatunicode_style= {
144+
staticconstunicodeStyleFormatunicode_style= {
143145
{
144146
{
145147
/* ─ */

‎src/include/fe_utils/mbprint.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* Multibyte character printing support for frontend code
4+
*
5+
*
6+
* Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
7+
* Portions Copyright (c) 1994, Regents of the University of California
8+
*
9+
* src/include/fe_utils/mbprint.h
10+
*
11+
*-------------------------------------------------------------------------
12+
*/
13+
#ifndefMBPRINT_H
14+
#defineMBPRINT_H
15+
16+
structlineptr
17+
{
18+
unsignedchar*ptr;
19+
intwidth;
20+
};
21+
22+
externunsignedchar*mbvalidate(unsignedchar*pwcs,intencoding);
23+
externintpg_wcswidth(constchar*pwcs,size_tlen,intencoding);
24+
externvoidpg_wcsformat(constunsignedchar*pwcs,size_tlen,intencoding,
25+
structlineptr*lines,intcount);
26+
externvoidpg_wcssize(constunsignedchar*pwcs,size_tlen,intencoding,
27+
int*width,int*height,int*format_size);
28+
29+
#endif/* MBPRINT_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp