From: Po Lu Date: Fri, 11 Aug 2023 06:55:21 +0000 (+0800) Subject: Minor adjustments to Android port X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=43cc92d6e41804cf1034e1d6e3cdf35e299bd196;p=emacs.git Minor adjustments to Android port * java/org/gnu/emacs/EmacsService.java (readDirectoryEntry): Also refrain from returning NULL or file names containing non-representable NULL bytes. * src/callproc.c (get_current_directory): Clean up by employing android_is_special_directory. --- diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index 379b1d30eda..cee823abc83 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java @@ -1503,9 +1503,13 @@ public final class EmacsService extends Service return entry; } - /* Skip this entry if its name cannot be represented. */ + /* Skip this entry if its name cannot be represented. NAME + can still be null here, since some Cursors are permitted to + return NULL if INDEX is not a string. */ - if (name.equals ("..") || name.equals (".") || name.contains ("/")) + if (name == null || name.equals ("..") + || name.equals (".") || name.contains ("/") + || name.contains ("\0")) continue; /* Now, look for its type. */ diff --git a/src/callproc.c b/src/callproc.c index 0645c2c3e18..dc37dfdc01f 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -170,10 +170,11 @@ get_current_directory (bool encode) /* If DIR is an asset directory or a content directory, return the home directory instead. */ - if (encode && (!strcmp (SSDATA (dir), "/assets") - || !strncmp (SSDATA (dir), "/assets/", 8) - || !strcmp (SSDATA (dir), "/content") - || !strncmp (SSDATA (dir), "/content/", 9))) + if (encode + && (android_is_special_directory (SSDATA (dir), + "/assets") + || android_is_special_directory (SSDATA (dir), + "/content"))) dir = build_string ("~"); #endif /* HAVE_ANDROID && ANDROID_STUBIFY */