time | Calls | line |
---|
| | 278 | function labels = fixLabelsForCompatibility(labels)
|
| | 279 | % Pre-R2016b, DimensionNames had almost no constraints, but there are new
|
| | 280 | % requirements to support new dot subscripting functionality added in R2016b.
|
| | 281 | % The old defaults met those requirements, so if the names are not (now) valid,
|
| | 282 | % they must have been intentionally changed from their old defaults (or perhaps
|
| | 283 | % DimensionNames{1} came from a column header in a file). In any case, to avoid
|
| | 284 | % breaking existing table code, modify any invalid names and warn.
|
| | 285 | import matlab.internal.datatypes.warningWithoutTrace
|
| | 286 |
|
< 0.001 | 3 | 287 | originalLabels = labels;
|
| | 288 | % Pre-R2016b and from R2019b onward, names are not required to be valid MATLAB
|
| | 289 | % identifiers. But post-R2019b, they must still be shorter than namelengthmax.
|
< 0.001 | 3 | 290 | matlab.internal.tabular.validateVariableNameLength(labels,'MATLAB:table:DimNameLengthMax');
|
| | 291 | % Pre-2016b, names were not required to be distinct from the list of reserved names.
|
< 0.001 | 3 | 292 | wasReserved = matlab.internal.tabular.private.metaDim.checkReservedNames(labels);
|
< 0.001 | 3 | 293 | if any(wasReserved)
|
| | 294 | warningWithoutTrace(message('MATLAB:table:DimnamesReservedNameConflictBackCompat',originalLabels{find(wasReserved,1)}));
|
| | 295 | labels(wasReserved) = matlab.lang.makeUniqueStrings(labels(wasReserved),labels(wasReserved),namelengthmax);
|
< 0.001 | 3 | 296 | end
|
< 0.001 | 3 | 297 | end
|
Other subfunctions in this file are not included in this listing.