projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bar Chart Dialog: Remove deprecated widgets
[pspp]
/
src
/
data
/
missing-values.c
diff --git
a/src/data/missing-values.c
b/src/data/missing-values.c
index c1a7469158ead5204e6da7fa5a4432ad36fc3bbb..9aba57e0e05fb6249764d2c5f778fb6337275a82 100644
(file)
--- a/
src/data/missing-values.c
+++ b/
src/data/missing-values.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 2005, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2009
, 2011, 2013
Free Software Foundation, Inc.
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
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
@@
-15,12
+15,16
@@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
-#include <data/missing-values.h>
+
+#include "data/missing-values.h"
+
#include <assert.h>
#include <stdlib.h>
#include <assert.h>
#include <stdlib.h>
-#include <data/variable.h>
-#include <libpspp/assertion.h>
-#include <libpspp/str.h>
+
+#include "data/variable.h"
+#include "libpspp/assertion.h"
+#include "libpspp/cast.h"
+#include "libpspp/str.h"
/* Types of user-missing values.
Invisible--use access functions defined below instead. */
/* Types of user-missing values.
Invisible--use access functions defined below instead. */
@@
-155,19
+159,23
@@
mv_add_value (struct missing_values *mv, const union value *v)
NOT_REACHED ();
}
NOT_REACHED ();
}
-/* Attempts to add S to the set of string missing values MV. S
- must contain exactly as many characters as MV's width.
- Returns true if successful, false if MV has no more room for
+/* Attempts to add S, which is LEN bytes long, to the set of string missing
+ values MV. Returns true if successful, false if MV has no more room for
missing values or if S is not an acceptable missing value. */
bool
missing values or if S is not an acceptable missing value. */
bool
-mv_add_str (struct missing_values *mv, const
char s[]
)
+mv_add_str (struct missing_values *mv, const
uint8_t s[], size_t len
)
{
union value v;
bool ok;
assert (mv->width > 0);
{
union value v;
bool ok;
assert (mv->width > 0);
+ while (len > mv->width)
+ if (s[--len] != ' ')
+ return false;
+
value_init (&v, mv->width);
value_init (&v, mv->width);
- memcpy (value_str_rw (&v, mv->width), s, mv->width);
+ buf_copy_rpad (CHAR_CAST (char *, value_str_rw (&v, mv->width)), mv->width,
+ CHAR_CAST (char *, s), len, ' ');
ok = mv_add_value (mv, &v);
value_destroy (&v, mv->width);
ok = mv_add_value (mv, &v);
value_destroy (&v, mv->width);
@@
-404,7
+412,7
@@
is_num_user_missing (const struct missing_values *mv, double d)
MV must be a set of string missing values.
S[] must contain exactly as many characters as MV's width. */
static bool
MV must be a set of string missing values.
S[] must contain exactly as many characters as MV's width. */
static bool
-is_str_user_missing (const struct missing_values *mv, const
char
s[])
+is_str_user_missing (const struct missing_values *mv, const
uint8_t
s[])
{
const union value *v = mv->values;
assert (mv->width > 0);
{
const union value *v = mv->values;
assert (mv->width > 0);
@@
-456,7
+464,7
@@
mv_is_num_missing (const struct missing_values *mv, double d,
MV must be a set of string missing values.
S[] must contain exactly as many characters as MV's width. */
bool
MV must be a set of string missing values.
S[] must contain exactly as many characters as MV's width. */
bool
-mv_is_str_missing (const struct missing_values *mv, const
char
s[],
+mv_is_str_missing (const struct missing_values *mv, const
uint8_t
s[],
enum mv_class class)
{
assert (mv->width > 0);
enum mv_class class)
{
assert (mv->width > 0);