Skip to content

Commit bf867b0

Browse files
committed
Enhancing of error message
1 parent 89bcb2c commit bf867b0

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

po/fr.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,8 +1301,8 @@ msgid "Unknown 'measure.vars' type %s at index %d of list"
13011301
msgstr "Type inconnu de 'measure.vars' %s à l'indice %d de la liste"
13021302

13031303
#: fmelt.c:187
1304-
msgid "One or more values in 'measure.vars' is invalid."
1305-
msgstr "Une ou plusieurs valeurs de 'measure.vars' ne sont pas valides."
1304+
msgid "One or more values in 'measure.vars' is invalid; please fix by removing: %s"
1305+
msgstr "Une ou plusieurs valeurs de 'measure.vars' ne sont pas valides; veuillez corriger en supprimant : %s"
13061306

13071307
#: fmelt.c:189
13081308
msgid "One or more values in 'id.vars' is invalid."

po/zh_CN.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,8 +1154,8 @@ msgid "Unknown 'measure.vars' type %s at index %d of list"
11541154
msgstr "未知'measure.vars'类型 %s,位于列表中 %d"
11551155

11561156
#: fmelt.c:187
1157-
msgid "One or more values in 'measure.vars' is invalid."
1158-
msgstr "'measure.vars'里,一或多个数值无效"
1157+
msgid "One or more values in 'measure.vars' is invalid; please fix by removing: %s"
1158+
msgstr "'measure.vars'里,一或多个数值无效;请通过删除以下数值来修复:%s"
11591159

11601160
#: fmelt.c:189
11611161
msgid "One or more values in 'id.vars' is invalid."

src/fmelt.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "data.table.h"
22
#include <Rdefines.h>
3+
4+
35
// #include <signal.h> // the debugging machinery + breakpoint aidee
46
// raise(SIGINT);
57

@@ -176,8 +178,12 @@ bool is_default_measure(SEXP vec) {
176178

177179
// maybe unlist, then unique, then set_diff.
178180
SEXP uniq_diff(SEXP int_or_list, int ncol, bool is_measure) {
181+
// Protect input list/vector, unlisting if necessary
179182
SEXP int_vec = PROTECT(isNewList(int_or_list) ? unlist_(int_or_list) : int_or_list);
183+
184+
// Check for duplicated elements in the input vector
180185
SEXP is_duplicated = PROTECT(duplicated(int_vec, FALSE));
186+
181187
int n_unique_cols = 0;
182188
SEXP invalid_columns = PROTECT(allocVector(INTSXP, length(int_vec)));
183189
int* invalid_col_ptr = INTEGER(invalid_columns);
@@ -206,16 +212,23 @@ SEXP uniq_diff(SEXP int_or_list, int ncol, bool is_measure) {
206212
}
207213
SEXP unique_col_numbers = PROTECT(allocVector(INTSXP, n_unique_cols));
208214
int unique_i = 0;
209-
for (int i=0; i<length(is_duplicated); ++i) {
215+
216+
// Populate the unique column numbers into the new vector
217+
for (int i = 0; i < length(is_duplicated); ++i) {
210218
if (!LOGICAL(is_duplicated)[i]) {
211219
INTEGER(unique_col_numbers)[unique_i++] = INTEGER(int_vec)[i];
212220
}
213221
}
222+
223+
// Apply set difference to get final unique column indices
214224
SEXP out = set_diff(unique_col_numbers, ncol);
215225
UNPROTECT(4);
216226
return out;
217227
}
218228

229+
230+
231+
219232
SEXP cols_to_int_or_list(SEXP cols, SEXP dtnames, bool is_measure) {
220233
switch(TYPEOF(cols)) {
221234
case STRSXP : return chmatch(cols, dtnames, 0);

0 commit comments

Comments
 (0)