Skip to content

Commit d4cfffa

Browse files
committed
sapi/phpdbg/help: make help texts const
1 parent 77d98de commit d4cfffa

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

sapi/phpdbg/phpdbg_help.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ const phpdbg_command_t phpdbg_help_commands[] = {
3838
}; /* }}} */
3939

4040
/* {{{ pretty_print. Formatting escapes and wrapping text in a string before printing it. */
41-
void pretty_print(char *text)
41+
static void pretty_print(const char *text)
4242
{
43-
char *new, *p, *q;
43+
char *new, *q;
4444

4545
const char *prompt_escape = phpdbg_get_prompt();
4646
size_t prompt_escape_len = strlen(prompt_escape);
@@ -60,6 +60,7 @@ void pretty_print(char *text)
6060
uint32_t line_count = 0; /* number printable chars on current line */
6161

6262
/* First pass calculates a safe size for the pretty print version */
63+
const char *p;
6364
for (p = text; *p; p++) {
6465
if (UNEXPECTED(p[0] == '*') && p[1] == '*') {
6566
size += bold_escape_len - 2;
@@ -143,9 +144,9 @@ void summary_print(phpdbg_command_t const * const cmd)
143144
}
144145

145146
/* {{{ get_help. Retries and formats text from the phpdbg help text table */
146-
static char *get_help(const char * const key)
147+
static const char *get_help(const char * const key)
147148
{
148-
phpdbg_help_text_t *p;
149+
const phpdbg_help_text_t *p;
149150

150151
/* Note that phpdbg_help_text is not assumed to be collated in key order. This is an
151152
inconvenience that means that help can't be logically grouped Not worth
@@ -201,8 +202,8 @@ static int get_command(
201202

202203
} /* }}} */
203204

204-
void phpdbg_do_help_cmd(char *type) { /* {{{ */
205-
char *help;
205+
void phpdbg_do_help_cmd(const char *type) { /* {{{ */
206+
const char *help;
206207

207208
if (!type) {
208209
pretty_print(get_help("overview!"));
@@ -329,7 +330,7 @@ PHPDBG_HELP(aliases) /* {{{ */
329330
* has a key ending in !
330331
*/
331332
#define CR "\n"
332-
phpdbg_help_text_t phpdbg_help_text[] = {
333+
const phpdbg_help_text_t phpdbg_help_text[] = {
333334

334335
/******************************** General Help Topics ********************************/
335336
{"overview!", CR

sapi/phpdbg/phpdbg_help.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ typedef struct _phpdbg_help_text_t {
4242
char *text;
4343
} phpdbg_help_text_t;
4444

45-
extern phpdbg_help_text_t phpdbg_help_text[];
45+
extern const phpdbg_help_text_t phpdbg_help_text[];
4646

47-
extern void phpdbg_do_help_cmd(char *type);
47+
extern void phpdbg_do_help_cmd(const char *type);
4848
#endif /* PHPDBG_HELP_H */

0 commit comments

Comments
 (0)