Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:whitespace cleanup
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:45c7ccd6395875db382c928167d6f34cc1699a09
User & Date: brandon 2016-04-06 20:41:54
Context
2016-04-06
21:06
change the collapse_hyphens function to replace double-hyphen with en dash check-in: 9122a3a97a user: brandon tags: trunk
20:41
whitespace cleanup check-in: 45c7ccd639 user: brandon tags: trunk
20:37
add more comments and fix some more quoting issues check-in: dd4b854be9 user: brandon tags: trunk
Changes

Changes to src/format_text.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
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
...
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/* 
 * format_text.c --- 
 * 
 * Copyright (C) 2014 Brandon Invergo <brandon@invergo.net>
 * 
 * Author: Brandon Invergo <brandon@invergo.net>
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include "format_text.h"
#include "spec_chars.c"

................................................................................
  uint8_t *ptr = u8_strpbrk (source, "{}");
  size_t len = u8_strlen (source);
  while (ptr != NULL)
    {
      if ((size_t)(ptr - source) < len)
        {
          u8_move (ptr, ptr + 1, (len - (ptr - source)) * sizeof (uint8_t));
        }      
      else if ((size_t)(ptr - source) == len)
        {
          source[len] = '\0';
        }
      len--;
      ptr = u8_strpbrk (source, "{}");
    }
................................................................................
          if (i == author_list->num_items - 1)
            {
              bt_set_format_text (name_format, BTN_FIRST, NULL, "",
                                  NULL, "");
              if (author_list->num_items > 1)
                bt_set_format_text (name_format, BTN_LAST, "and ", NULL,
                                    NULL, NULL);
            }                
          author_str_form = bt_format_name (name, name_format);
          u_author_str_form = u8_strconv_from_locale(author_str_form);
          len = u8_strlen (u_author_str_form);
          if (len + pos >= AUTHBUFSIZE - 7)
            {
              u8_strncpy (author_buffer + pos, "et al.", 6);
              pos += 6;
................................................................................
  const char *locale_encoding = locale_charset ();
  size_t len = u8_strlen (text);
  size_t remain = len;
  size_t indent_len = u8_strlen (indent);
  int line_width = 0;
  char *breaks;
  size_t i, line_start_i = 0;
  
  if (len > BUFSIZE || indent_len > BUFSIZE)
    {
      return;
    }
  if (column < 20 || u8_strwidth (text, locale_encoding) < column - indent_len)
    {
      u8_strncpy (buffer, indent, indent_len);
|
|
|
|
|

|




|




|







 







|







 







|







 







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
...
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/*
 * format_text.c ---
 *
 * Copyright (C) 2014, 2016 Brandon Invergo <brandon@invergo.net>
 *
 * Author: Brandon Invergo <brandon@invergo.net>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include "format_text.h"
#include "spec_chars.c"

................................................................................
  uint8_t *ptr = u8_strpbrk (source, "{}");
  size_t len = u8_strlen (source);
  while (ptr != NULL)
    {
      if ((size_t)(ptr - source) < len)
        {
          u8_move (ptr, ptr + 1, (len - (ptr - source)) * sizeof (uint8_t));
        }
      else if ((size_t)(ptr - source) == len)
        {
          source[len] = '\0';
        }
      len--;
      ptr = u8_strpbrk (source, "{}");
    }
................................................................................
          if (i == author_list->num_items - 1)
            {
              bt_set_format_text (name_format, BTN_FIRST, NULL, "",
                                  NULL, "");
              if (author_list->num_items > 1)
                bt_set_format_text (name_format, BTN_LAST, "and ", NULL,
                                    NULL, NULL);
            }
          author_str_form = bt_format_name (name, name_format);
          u_author_str_form = u8_strconv_from_locale(author_str_form);
          len = u8_strlen (u_author_str_form);
          if (len + pos >= AUTHBUFSIZE - 7)
            {
              u8_strncpy (author_buffer + pos, "et al.", 6);
              pos += 6;
................................................................................
  const char *locale_encoding = locale_charset ();
  size_t len = u8_strlen (text);
  size_t remain = len;
  size_t indent_len = u8_strlen (indent);
  int line_width = 0;
  char *breaks;
  size_t i, line_start_i = 0;

  if (len > BUFSIZE || indent_len > BUFSIZE)
    {
      return;
    }
  if (column < 20 || u8_strwidth (text, locale_encoding) < column - indent_len)
    {
      u8_strncpy (buffer, indent, indent_len);

Changes to src/format_text.h.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* 
 * format_text.h --- 
 * 
 * Copyright (C) 2014 Brandon Invergo <brandon@invergo.net>
 * 
 * Author: Brandon Invergo <brandon@invergo.net>
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef FORMAT_TEXT_H
#define FORMAT_TEXT_H

|
|
|
|
|

|




|




|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * format_text.h ---
 *
 * Copyright (C) 2014, 2016 Brandon Invergo <brandon@invergo.net>
 *
 * Author: Brandon Invergo <brandon@invergo.net>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef FORMAT_TEXT_H
#define FORMAT_TEXT_H

Changes to src/paperbib.c.

1
2
3
4
5
6
7
8
9
10
11
..
31
32
33
34
35
36
37
38

39
40
41
42
43
44
45
..
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/* 
 * paperbib.c --- Print bibliographic information for a BibTeX entry
 * 
 * Copyright (C) 2014 Brandon Invergo <brandon@invergo.net>
 * 
 * Author: Brandon Invergo <brandon@invergo.net>
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
................................................................................
  "The BibTeX file is supplied via stdin.  The citation entry to format "
  "is specified by its citation key, KEY.  The formatted citation is then "
  "printed to stdout";

static char args_doc[] = "KEY";

static struct argp_option options[] = {
  {"max-authors", 'a', "NUM", 0, "The maximum number of authors to list before truncating with 'et al.' (0 for no limit; default 3)"},

  {"wrap", 'w', "NUM", 0, "Wrap the output at column NUM (default no wrap)"},
  {"indent", 'i', "STR", 0, "Prefix each line of the output with STR"},
  {0}
};

struct arguments
{
................................................................................
{
  uint8_t *title;
  uint8_t *author;
  uint8_t *year;
  uint8_t *journal;
  uint8_t *volume;
  uint8_t *number;
  uint8_t *pages;  
};

 
AST *
get_bibtex_entry (char *key, AST *bibtex_entry)
{
  AST *bibtex_tree;
................................................................................
      else if (!u8_strcmp (field_name, "journal"))
        {
          debrace (value_clean, value_text);
          value_len = u8_strlen (value_clean);
          doc.journal = (uint8_t *)malloc (value_len * sizeof (uint8_t) + 1);
          u8_strncpy (doc.journal, value_text, value_len);
          doc.journal[value_len] = '\0';
          value_clean[0] = '\0'; 
        }
      else if (!u8_strcmp (field_name, "pages"))
        {
          collapse_hyphens (value_clean, value_text);
          value_len = u8_strlen (value_clean);
          doc.pages = (uint8_t *)malloc (value_len * sizeof (uint8_t) + 1);
          u8_strncpy (doc.pages, value_text, value_len);



|







 







|
>







 







|







 







|







1
2
3
4
5
6
7
8
9
10
11
..
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
..
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
...
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/* 
 * paperbib.c --- Print bibliographic information for a BibTeX entry
 * 
 * Copyright (C) 2014, 2016 Brandon Invergo <brandon@invergo.net>
 * 
 * Author: Brandon Invergo <brandon@invergo.net>
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
................................................................................
  "The BibTeX file is supplied via stdin.  The citation entry to format "
  "is specified by its citation key, KEY.  The formatted citation is then "
  "printed to stdout";

static char args_doc[] = "KEY";

static struct argp_option options[] = {
  {"max-authors", 'a', "NUM", 0, "The maximum number of authors to list before "
   "truncating with 'et al.' (0 for no limit; default 3)"},
  {"wrap", 'w', "NUM", 0, "Wrap the output at column NUM (default no wrap)"},
  {"indent", 'i', "STR", 0, "Prefix each line of the output with STR"},
  {0}
};

struct arguments
{
................................................................................
{
  uint8_t *title;
  uint8_t *author;
  uint8_t *year;
  uint8_t *journal;
  uint8_t *volume;
  uint8_t *number;
  uint8_t *pages;
};

 
AST *
get_bibtex_entry (char *key, AST *bibtex_entry)
{
  AST *bibtex_tree;
................................................................................
      else if (!u8_strcmp (field_name, "journal"))
        {
          debrace (value_clean, value_text);
          value_len = u8_strlen (value_clean);
          doc.journal = (uint8_t *)malloc (value_len * sizeof (uint8_t) + 1);
          u8_strncpy (doc.journal, value_text, value_len);
          doc.journal[value_len] = '\0';
          value_clean[0] = '\0';
        }
      else if (!u8_strcmp (field_name, "pages"))
        {
          collapse_hyphens (value_clean, value_text);
          value_len = u8_strlen (value_clean);
          doc.pages = (uint8_t *)malloc (value_len * sizeof (uint8_t) + 1);
          u8_strncpy (doc.pages, value_text, value_len);

Changes to src/paperbib.h.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* 
 * paperbib.h --- 
 * 
 * Copyright (C) 2014 Brandon Invergo <brandon@invergo.net>
 * 
 * Author: Brandon Invergo <brandon@invergo.net>
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef PAPERBIB_H
#define PAPERBIB_H

|
|
|
|
|

|




|




|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 * paperbib.h ---
 *
 * Copyright (C) 2014, 2016 Brandon Invergo <brandon@invergo.net>
 *
 * Author: Brandon Invergo <brandon@invergo.net>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef PAPERBIB_H
#define PAPERBIB_H