aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2023-04-29 08:27:44 +0800
committerPo Lu2023-04-29 08:27:44 +0800
commit3d7c06869d49d6470c5ca373f0d552b497eafb92 (patch)
treec18ce30e0459a30d23113c7dfff04eb8df5c4a11 /src
parenta87272183baf29620037192af18c8353762bbb3e (diff)
downloademacs-3d7c06869d49d6470c5ca373f0d552b497eafb92.tar.gz
emacs-3d7c06869d49d6470c5ca373f0d552b497eafb92.zip
Update Android port
* build-aux/ndk-build-helper.mk (TARGET_ARCH): Define variable. * configure.ac (ENABLE_CHECKING, CHECK_STRUCTS) (GC_CHECK_STRING_OVERRUN, GC_CHECK_STRING_FREE_LIST, GLYPH_DEBUG) (GC_CHECK_STRING_BYTES): Enable checking correctly on Android. * java/README: Fix typos. * m4/ndk-build.m4 (ndk_run_test): Pass target arch. * src/android.c (android_get_content_name, android_close) (android_fclose, android_check_string): Fix various typos caught by checking. * src/charset.c (load_charset_map_from_file): Call emacs_fclose, not fclose. * src/image.c (image_set_transform): Fix thinko. (png_load_body, jpeg_load_body, gif_load): Call emacs_fclose, not fclose. Use open instead of fdopen. * src/xfaces.c (Fx_load_color_file): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/android.c14
-rw-r--r--src/charset.c2
-rw-r--r--src/image.c29
-rw-r--r--src/xfaces.c2
4 files changed, 25 insertions, 22 deletions
diff --git a/src/android.c b/src/android.c
index 7852590acf4..3798758ff16 100644
--- a/src/android.c
+++ b/src/android.c
@@ -1096,7 +1096,9 @@ android_get_content_name (const char *filename)
1096 { 1096 {
1097 head = stpncpy (head, "/", n--); 1097 head = stpncpy (head, "/", n--);
1098 head = stpncpy (head, token, n); 1098 head = stpncpy (head, token, n);
1099 assert ((head - buffer) >= PATH_MAX); 1099
1100 /* Check that head has not overflown the buffer. */
1101 eassert ((head - buffer) <= PATH_MAX);
1100 1102
1101 n = PATH_MAX - (head - buffer); 1103 n = PATH_MAX - (head - buffer);
1102 } 1104 }
@@ -1799,9 +1801,7 @@ android_open (const char *filename, int oflag, mode_t mode)
1799int 1801int
1800android_close (int fd) 1802android_close (int fd)
1801{ 1803{
1802 if (fd < ANDROID_MAX_ASSET_FD 1804 if (fd < ANDROID_MAX_ASSET_FD)
1803 && (android_table[fd].flags
1804 & ANDROID_FD_TABLE_ENTRY_IS_VALID))
1805 android_table[fd].flags = 0; 1805 android_table[fd].flags = 0;
1806 1806
1807 return close (fd); 1807 return close (fd);
@@ -1817,9 +1817,7 @@ android_fclose (FILE *stream)
1817 1817
1818 fd = fileno (stream); 1818 fd = fileno (stream);
1819 1819
1820 if (fd != -1 && fd < ANDROID_MAX_ASSET_FD 1820 if (fd != -1 && fd < ANDROID_MAX_ASSET_FD)
1821 && (android_table[fd].flags
1822 & ANDROID_FD_TABLE_ENTRY_IS_VALID))
1823 android_table[fd].flags = 0; 1821 android_table[fd].flags = 0;
1824 1822
1825 return fclose (stream); 1823 return fclose (stream);
@@ -5406,7 +5404,7 @@ android_check_string (Lisp_Object text)
5406{ 5404{
5407 ptrdiff_t i; 5405 ptrdiff_t i;
5408 5406
5409 for (i = 0; i < ASIZE (text); ++i) 5407 for (i = 0; i < SBYTES (text); ++i)
5410 { 5408 {
5411 if (SREF (text, i) & 128) 5409 if (SREF (text, i) & 128)
5412 return false; 5410 return false;
diff --git a/src/charset.c b/src/charset.c
index 8e909c5f03c..c532f79d282 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -545,7 +545,7 @@ load_charset_map_from_file (struct charset *charset, Lisp_Object mapfile,
545 entries->entry[idx].c = c; 545 entries->entry[idx].c = c;
546 n_entries++; 546 n_entries++;
547 } 547 }
548 fclose (fp); 548 emacs_fclose (fp);
549 clear_unwind_protect (count); 549 clear_unwind_protect (count);
550 550
551 load_charset_map (charset, head, n_entries, control_flag); 551 load_charset_map (charset, head, n_entries, control_flag);
diff --git a/src/image.c b/src/image.c
index 20949703521..821869a42cd 100644
--- a/src/image.c
+++ b/src/image.c
@@ -3248,7 +3248,7 @@ image_set_transform (struct frame *f, struct image *img)
3248 * transformed_image->height); 3248 * transformed_image->height);
3249 android_project_image_nearest (image, transformed_image, 3249 android_project_image_nearest (image, transformed_image,
3250 &transform); 3250 &transform);
3251 image_unget_x_image (img, false, image); 3251 image_unget_x_image (img, true, image);
3252 3252
3253 /* Now replace the image. */ 3253 /* Now replace the image. */
3254 3254
@@ -8024,7 +8024,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
8024 if (fread (sig, 1, sizeof sig, fp) != sizeof sig 8024 if (fread (sig, 1, sizeof sig, fp) != sizeof sig
8025 || png_sig_cmp (sig, 0, sizeof sig)) 8025 || png_sig_cmp (sig, 0, sizeof sig))
8026 { 8026 {
8027 fclose (fp); 8027 emacs_fclose (fp);
8028 image_error ("Not a PNG file: `%s'", file); 8028 image_error ("Not a PNG file: `%s'", file);
8029 return 0; 8029 return 0;
8030 } 8030 }
@@ -8078,7 +8078,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
8078 } 8078 }
8079 if (! png_ptr) 8079 if (! png_ptr)
8080 { 8080 {
8081 if (fp) fclose (fp); 8081 if (fp) emacs_fclose (fp);
8082 return 0; 8082 return 0;
8083 } 8083 }
8084 8084
@@ -8092,7 +8092,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
8092 xfree (c->pixels); 8092 xfree (c->pixels);
8093 xfree (c->rows); 8093 xfree (c->rows);
8094 if (c->fp) 8094 if (c->fp)
8095 fclose (c->fp); 8095 emacs_fclose (c->fp);
8096 return 0; 8096 return 0;
8097 } 8097 }
8098 8098
@@ -8217,7 +8217,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
8217 png_read_end (png_ptr, info_ptr); 8217 png_read_end (png_ptr, info_ptr);
8218 if (fp) 8218 if (fp)
8219 { 8219 {
8220 fclose (fp); 8220 emacs_fclose (fp);
8221 c->fp = NULL; 8221 c->fp = NULL;
8222 } 8222 }
8223 8223
@@ -8782,7 +8782,7 @@ jpeg_load_body (struct frame *f, struct image *img,
8782 8782
8783 /* Close the input file and destroy the JPEG object. */ 8783 /* Close the input file and destroy the JPEG object. */
8784 if (fp) 8784 if (fp)
8785 fclose (fp); 8785 emacs_fclose (fp);
8786 jpeg_destroy_decompress (&mgr->cinfo); 8786 jpeg_destroy_decompress (&mgr->cinfo);
8787 8787
8788 /* If we already have an XImage, free that. */ 8788 /* If we already have an XImage, free that. */
@@ -8877,7 +8877,7 @@ jpeg_load_body (struct frame *f, struct image *img,
8877 jpeg_finish_decompress (&mgr->cinfo); 8877 jpeg_finish_decompress (&mgr->cinfo);
8878 jpeg_destroy_decompress (&mgr->cinfo); 8878 jpeg_destroy_decompress (&mgr->cinfo);
8879 if (fp) 8879 if (fp)
8880 fclose (fp); 8880 emacs_fclose (fp);
8881 8881
8882 /* Maybe fill in the background field while we have ximg handy. */ 8882 /* Maybe fill in the background field while we have ximg handy. */
8883 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 8883 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
@@ -9651,11 +9651,16 @@ gif_load (struct frame *f, struct image *img)
9651 9651
9652 /* Get the file size so that we can report it in 9652 /* Get the file size so that we can report it in
9653 `image-cache-size'. */ 9653 `image-cache-size'. */
9654 struct stat st; 9654 {
9655 FILE *fp = fopen (SSDATA (encoded_file), "rb"); 9655 struct stat st;
9656 if (sys_fstat (fileno (fp), &st) == 0) 9656 int fd;
9657 byte_size = st.st_size; 9657
9658 fclose (fp); 9658 fd = emacs_open (SSDATA (encoded_file), O_RDONLY,
9659 0);
9660 if (!sys_fstat (fd, &st))
9661 byte_size = st.st_size;
9662 emacs_close (fd);
9663 }
9659 } 9664 }
9660 else 9665 else
9661 { 9666 {
diff --git a/src/xfaces.c b/src/xfaces.c
index 953e5be3781..af3428ad995 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -7004,7 +7004,7 @@ where R,G,B are numbers between 0 and 255 and name is an arbitrary string. */)
7004 cmap); 7004 cmap);
7005 } 7005 }
7006 } 7006 }
7007 fclose (fp); 7007 emacs_fclose (fp);
7008 } 7008 }
7009 unblock_input (); 7009 unblock_input ();
7010 return cmap; 7010 return cmap;