changeset 14802:d5aee269b770

strread.m: catch unsupported ML format specifiers (bug #36464)
author Philip Nienhuis <prnienhuis@users.sf.net>
date Mon, 25 Jun 2012 22:25:56 +0200
parents 3c5e6971064c
children 616981c9907c
files scripts/io/strread.m
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/io/strread.m	Sun Jun 24 21:42:58 2012 +0200
+++ b/scripts/io/strread.m	Mon Jun 25 22:25:56 2012 +0200
@@ -301,6 +301,13 @@
     ## Format conversion specifiers following literals w/o space/delim
     ## in between are separate now.  Separate those w trailing literals
     idy2 = find (! cellfun ("isempty", strfind (fmt_words, "%")));
+
+    ## Check for unsupported format specifiers
+    errpat = '(\[.*\]|[cq]|[nfdu]8|[nfdu]16|[nfdu]32|[nfdu]64)';
+    if (! all (cellfun ("isempty", regexp (fmt_words(idy2), errpat))))
+      error ("strread: %q, %c, %[] or bit width format specifiers are not supported yet.");
+    endif
+
     a = strfind (fmt_words(idy2), "%");
     b = regexp (fmt_words(idy2), '[nfdus]', 'end');
     for jj = 1:numel (a)
@@ -931,3 +938,19 @@
 %! assert (isempty (b));
 %! assert (isempty (c));
 
+%% Unsupported format specifiers
+%!test
+%!error <format specifiers are not supported> strread ('a', '%c')
+%!error <format specifiers are not supported> strread ('a', '%*c %d')
+%!error <format specifiers are not supported> strread ('a', '%q')
+%!error <format specifiers are not supported> strread ('a', '%*q %d')
+%!error <format specifiers are not supported> strread ('a', '%[a]')
+%!error <format specifiers are not supported> strread ('a', '%*[a] %d')
+%!error <format specifiers are not supported> strread ('a', '%[^a]')
+%!error <format specifiers are not supported> strread ('a', '%*[â] %d')
+%!error <format specifiers are not supported> strread ('a', '%d8')
+%!error <format specifiers are not supported> strread ('a', '%*d8 %s')
+%!error <format specifiers are not supported> strread ('a', '%f64')
+%!error <format specifiers are not supported> strread ('a', '%*f64 %s')
+%!error <format specifiers are not supported> strread ('a', '%u32')
+%!error <format specifiers are not supported> strread ('a', '%*u32 %d')