Gitweb links:
...log
http://git.netsurf-browser.org/libpencil.git/shortlog/b8f47e07d069d480f8cd53926984b1d8fcf9aa31
...commit
http://git.netsurf-browser.org/libpencil.git/commit/b8f47e07d069d480f8cd53926984b1d8fcf9aa31
...tree
http://git.netsurf-browser.org/libpencil.git/tree/b8f47e07d069d480f8cd53926984b1d8fcf9aa31
The branch, master has been updated
via b8f47e07d069d480f8cd53926984b1d8fcf9aa31 (commit)
from 42430ca115c0b52ca262382ccc476d227d1655c4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libpencil.git/commit/?id=b8f47e07d069d480f8cd53926984b1d8fcf9aa31
commit b8f47e07d069d480f8cd53926984b1d8fcf9aa31
Author: John-Mark Bell <[email protected]>
Commit: John-Mark Bell <[email protected]>
Fix build with GCC 10
GCC 10 objected to the attempt to pass-through RUfl errors (this
was safe, given rufl_code and pencil_code have identical values,
even though they are strictly different types). Fix this by
applying explicit casts.
Additionally, GCC 10 warned about the use of strncpy where the
number of bytes to copy was the same as the destination buffer
size. In this particular case, this was safe (as there is no
terminating NUL to be applied here, given the field is fixed
width in the Draw file format). Fix this by using memcpy
instead, as this better reflects the intent.
diff --git a/include/pencil.h b/include/pencil.h
index 9205d5a..d4f1ac3 100644
--- a/include/pencil.h
+++ b/include/pencil.h
@@ -17,7 +17,7 @@ struct pencil_diagram;
typedef enum {
- pencil_OK,
+ pencil_OK = rufl_OK,
pencil_OUT_OF_MEMORY = rufl_OUT_OF_MEMORY,
pencil_FONT_MANAGER_ERROR = rufl_FONT_MANAGER_ERROR,
pencil_FONT_NOT_FOUND = rufl_FONT_NOT_FOUND,
diff --git a/src/pencil_save.c b/src/pencil_save.c
index c2cd390..426423a 100644
--- a/src/pencil_save.c
+++ b/src/pencil_save.c
@@ -107,8 +107,9 @@ pencil_code pencil_save_drawfile(struct pencil_diagram
*diagram,
header->tag[3] = 'w';
header->major_version = 201;
header->minor_version = 0;
- strncpy(header->source, source, 12);
- for (i = strlen(source); i < 12; i++)
+ i = strlen(source);
+ memcpy(header->source, source, (i < 12) ? i : 12);
+ for (; i < 12; i++)
header->source[i] = ' ';
header->bbox = context.bbox;
b = (char *) buffer + sizeof(drawfile_diagram_base);
@@ -200,14 +201,14 @@ void pencil_save_pass1(struct pencil_save_context
*context,
item->x, item->y,
pencil_save_pass1_text_callback, context);
if (code != rufl_OK)
- context->code = code;
+ context->code = (pencil_code) code;
if (context->code != pencil_OK)
return;
code = rufl_font_bbox(item->font_family, item->font_style,
item->font_size, &bbox);
if (code != rufl_OK)
- context->code = code;
+ context->code = (pencil_code) code;
if (context->code != pencil_OK)
return;
@@ -215,7 +216,7 @@ void pencil_save_pass1(struct pencil_save_context *context,
item->font_size, item->text, strlen(item->text),
&width);
if (code != rufl_OK)
- context->code = code;
+ context->code = (pencil_code) code;
if (context->code != pencil_OK)
return;
@@ -369,8 +370,10 @@ void pencil_save_pass2(struct pencil_save_context *context,
group = true;
object->type = drawfile_TYPE_GROUP;
object->size = 36;
- strncpy(object->data.group.name, item->group_name, 12);
- for (i = strlen(item->group_name); i < 12; i++)
+ i = strlen(item->group_name);
+ memcpy(object->data.group.name, item->group_name,
+ (i < 12) ? i : 12);
+ for (; i < 12; i++)
object->data.group.name[i] = ' ';
object->data.group.bbox.x0 = item->bbox.x0;
object->data.group.bbox.y0 = item->bbox.y0;
@@ -385,7 +388,7 @@ void pencil_save_pass2(struct pencil_save_context *context,
item->x, item->y,
pencil_save_pass2_text_callback, context);
if (code != rufl_OK)
- context->code = code;
+ context->code = (pencil_code) code;
if (context->code != pencil_OK)
return;
break;
-----------------------------------------------------------------------
Summary of changes:
include/pencil.h | 2 +-
src/pencil_save.c | 19 +++++++++++--------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/include/pencil.h b/include/pencil.h
index 9205d5a..d4f1ac3 100644
--- a/include/pencil.h
+++ b/include/pencil.h
@@ -17,7 +17,7 @@ struct pencil_diagram;
typedef enum {
- pencil_OK,
+ pencil_OK = rufl_OK,
pencil_OUT_OF_MEMORY = rufl_OUT_OF_MEMORY,
pencil_FONT_MANAGER_ERROR = rufl_FONT_MANAGER_ERROR,
pencil_FONT_NOT_FOUND = rufl_FONT_NOT_FOUND,
diff --git a/src/pencil_save.c b/src/pencil_save.c
index c2cd390..426423a 100644
--- a/src/pencil_save.c
+++ b/src/pencil_save.c
@@ -107,8 +107,9 @@ pencil_code pencil_save_drawfile(struct pencil_diagram
*diagram,
header->tag[3] = 'w';
header->major_version = 201;
header->minor_version = 0;
- strncpy(header->source, source, 12);
- for (i = strlen(source); i < 12; i++)
+ i = strlen(source);
+ memcpy(header->source, source, (i < 12) ? i : 12);
+ for (; i < 12; i++)
header->source[i] = ' ';
header->bbox = context.bbox;
b = (char *) buffer + sizeof(drawfile_diagram_base);
@@ -200,14 +201,14 @@ void pencil_save_pass1(struct pencil_save_context
*context,
item->x, item->y,
pencil_save_pass1_text_callback, context);
if (code != rufl_OK)
- context->code = code;
+ context->code = (pencil_code) code;
if (context->code != pencil_OK)
return;
code = rufl_font_bbox(item->font_family, item->font_style,
item->font_size, &bbox);
if (code != rufl_OK)
- context->code = code;
+ context->code = (pencil_code) code;
if (context->code != pencil_OK)
return;
@@ -215,7 +216,7 @@ void pencil_save_pass1(struct pencil_save_context *context,
item->font_size, item->text, strlen(item->text),
&width);
if (code != rufl_OK)
- context->code = code;
+ context->code = (pencil_code) code;
if (context->code != pencil_OK)
return;
@@ -369,8 +370,10 @@ void pencil_save_pass2(struct pencil_save_context *context,
group = true;
object->type = drawfile_TYPE_GROUP;
object->size = 36;
- strncpy(object->data.group.name, item->group_name, 12);
- for (i = strlen(item->group_name); i < 12; i++)
+ i = strlen(item->group_name);
+ memcpy(object->data.group.name, item->group_name,
+ (i < 12) ? i : 12);
+ for (; i < 12; i++)
object->data.group.name[i] = ' ';
object->data.group.bbox.x0 = item->bbox.x0;
object->data.group.bbox.y0 = item->bbox.y0;
@@ -385,7 +388,7 @@ void pencil_save_pass2(struct pencil_save_context *context,
item->x, item->y,
pencil_save_pass2_text_callback, context);
if (code != rufl_OK)
- context->code = code;
+ context->code = (pencil_code) code;
if (context->code != pencil_OK)
return;
break;
--
RISC OS Drawfile export library
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]