Not logged in

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

Overview
Comment:change the collapse_hyphens function to replace double-hyphen with en dash
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:9122a3a97ae717b8e24004ba4dbf490574670226
User & Date: brandon 2016-04-06 21:06:23
Context
2016-04-06
21:24
add comments check-in: 63c16ee7d0 user: brandon tags: trunk
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
Changes

Changes to src/format_text.c.

69
70
71
72
73
74
75
76
77
78
79

80
81
82
83
84
85
86
87
88
89
90
    }
  u8_strncpy (dest, source, len + 1);
  dest[len + 1] = '\0';
}

 
void
collapse_hyphens (uint8_t *dest, uint8_t *source)
{
  uint8_t *ptr = u8_strstr (source, "--");
  size_t len = u8_strlen (source);

  while (ptr != NULL)
    {
      u8_move (ptr + 1, ptr + 2, (len - (ptr - source) - 1) * sizeof (uint8_t));
      len--;
      ptr = u8_strstr (source, "--");
    }
  u8_strncpy (dest, source, len + 1);
  dest[len + 1] = '\0';
}

void







|



>


<
|







69
70
71
72
73
74
75
76
77
78
79
80
81
82

83
84
85
86
87
88
89
90
    }
  u8_strncpy (dest, source, len + 1);
  dest[len + 1] = '\0';
}

 
void
double_hyphen_to_en_dash (uint8_t *dest, uint8_t *source)
{
  uint8_t *ptr = u8_strstr (source, "--");
  size_t len = u8_strlen (source);
  size_t pos = 0;
  while (ptr != NULL)
    {

      replace_spec_char (ptr, 2, 0x2013, ptr-source, &len);
      ptr = u8_strstr (source, "--");
    }
  u8_strncpy (dest, source, len + 1);
  dest[len + 1] = '\0';
}

void

Changes to src/format_text.h.

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <btparse.h>

#define BUFSIZE 50000
#define AUTHBUFSIZE 50000

int append_text (uint8_t *, uint8_t *, int);
void debrace (uint8_t *, uint8_t *);
void collapse_hyphens (uint8_t *, uint8_t *);
void replace_spec_char (uint8_t *, int, ucs4_t, size_t, size_t *);
void special_chars (uint8_t *, uint8_t *);
void format_authors (char *, uint8_t *, int);
void wrap (uint8_t *, uint8_t *, uint8_t *, int);

#endif









|








39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <btparse.h>

#define BUFSIZE 50000
#define AUTHBUFSIZE 50000

int append_text (uint8_t *, uint8_t *, int);
void debrace (uint8_t *, uint8_t *);
void double_hyphen_to_en_dash (uint8_t *, uint8_t *);
void replace_spec_char (uint8_t *, int, ucs4_t, size_t, size_t *);
void special_chars (uint8_t *, uint8_t *);
void format_authors (char *, uint8_t *, int);
void wrap (uint8_t *, uint8_t *, uint8_t *, int);

#endif


Changes to src/paperbib.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
...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/* 
 * 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.
 * 
 * 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 "paperbib.h"

 
................................................................................
          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);
          doc.pages[value_len] = '\0';
          value_clean[0] = '\0';
        }
      else if (!u8_strcmp (field_name, "volume"))
|

|

|

|




|




|







 







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
 * 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.
 *
 * 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 "paperbib.h"

 
................................................................................
          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"))
        {
          double_hyphen_to_en_dash (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);
          doc.pages[value_len] = '\0';
          value_clean[0] = '\0';
        }
      else if (!u8_strcmp (field_name, "volume"))