From 5a6404cff47a7d35da10ada4d57ec9eb15c1dfab Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 1 Nov 2006 17:12:57 +0000 Subject: updated for version 7.0-156 --- src/feature.h | 2 +- src/mbyte.c | 2 +- src/memfile.c | 2 +- src/memline.c | 8 ++- src/os_amiga.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++----------- src/os_amiga.h | 32 ++++++++---- src/pty.c | 6 +-- src/version.c | 2 + 8 files changed, 164 insertions(+), 46 deletions(-) diff --git a/src/feature.h b/src/feature.h index 2d49b5c41..c23ade4cc 100644 --- a/src/feature.h +++ b/src/feature.h @@ -1133,7 +1133,7 @@ /* * +ARP Amiga only. Use arp.library, DOS 2.0 is not required. */ -#ifndef NO_ARP +#if !defined(NO_ARP) && !defined(__amigaos4__) # define FEAT_ARP #endif diff --git a/src/mbyte.c b/src/mbyte.c index 085b0eac8..846ce98f7 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -667,7 +667,7 @@ codepage_invalid: * API */ n = IsDBCSLeadByteEx(enc_dbcs, (BYTE)i) ? 2 : 1; #else -# ifdef MACOS +# if defined(MACOS) || defined(__amigaos4__) /* * if mblen() is not available, character which MSB is turned on * are treated as leading byte character. (note : This assumption diff --git a/src/memfile.c b/src/memfile.c index 0f0709119..ba2a379af 100644 --- a/src/memfile.c +++ b/src/memfile.c @@ -655,7 +655,7 @@ mf_sync(mfp, flags) # endif #endif #ifdef AMIGA -# ifdef __AROS__ +# if defined(__AROS__) || defined(__amigaos4__) if (fsync(mfp->mf_fd) != 0) status = FAIL; # else diff --git a/src/memline.c b/src/memline.c index 5d43dc3f0..80a870a0e 100644 --- a/src/memline.c +++ b/src/memline.c @@ -55,10 +55,14 @@ # include #endif -#ifdef SASC +#if defined(SASC) || defined(__amigaos4__) # include /* for Open() and Close() */ #endif +#ifdef HAVE_ERRNO_H +# include +#endif + typedef struct block0 ZERO_BL; /* contents of the first block */ typedef struct pointer_block PTR_BL; /* contents of a pointer block */ typedef struct data_block DATA_BL; /* contents of a data block */ @@ -4481,7 +4485,7 @@ ml_updatechunk(buf, line, len, updtype) curchnk = buf->b_ml.ml_chunksize + curix; if (updtype == ML_CHNK_DELLINE) - len *= -1; + len = -len; curchnk->mlcs_totalsize += len; if (updtype == ML_CHNK_ADDLINE) { diff --git a/src/os_amiga.c b/src/os_amiga.c index 3728bebf1..07000dcb4 100644 --- a/src/os_amiga.c +++ b/src/os_amiga.c @@ -30,20 +30,31 @@ # include # include # include -# include # include -#else -# include -# include -# include -# include #endif +/* XXX These are included from os_amiga.h +#include +#include +#include +*/ + #include +#include #include /* for 2.0 functions */ #include +/* From version 4 of AmigaOS, several system structures must be allocated + * and freed using system functions. "struct AnchorPath" is one. + */ +#ifdef __amigaos4__ +# include +# define free_fib(x) FreeDosObject(DOS_FIB, x) +#else +# define free_fib(x) vim_free(fib) +#endif + #if defined(LATTICE) && !defined(SASC) && defined(FEAT_ARP) # include #endif @@ -56,7 +67,9 @@ #undef FALSE #define FALSE (0) -#if !defined(AZTEC_C) && !defined(__AROS__) +#ifdef __amigaos4__ +# define dos_packet(a, b, c) DoPkt(a, b, c, 0, 0, 0, 0) +#elif !defined(AZTEC_C) && !defined(__AROS__) static long dos_packet __ARGS((struct MsgPort *, long, long)); #endif static int lock2name __ARGS((BPTR lock, char_u *buf, long len)); @@ -68,7 +81,9 @@ static BPTR raw_in = (BPTR)NULL; static BPTR raw_out = (BPTR)NULL; static int close_win = FALSE; /* set if Vim opened the window */ +#ifndef __amigaos4__ /* Use autoopen for AmigaOS4 */ struct IntuitionBase *IntuitionBase = NULL; +#endif #ifdef FEAT_ARP struct ArpBase *ArpBase = NULL; #endif @@ -186,9 +201,17 @@ mch_char_avail() mch_avail_mem(special) int special; { +#ifdef __amigaos4__ + return (long_u)AvailMem(MEMF_ANY); +#else return (long_u)AvailMem(special ? (long)MEMF_CHIP : (long)MEMF_ANY); +#endif } +/* + * Waits a specified amount of time, or until input arrives if + * ignoreinput is FALSE. + */ void mch_delay(msec, ignoreinput) long msec; @@ -252,6 +275,7 @@ mch_init() out_flush(); wb_window = NULL; +#ifndef __amigaos4__ if ((IntuitionBase = (struct IntuitionBase *) OpenLibrary((UBYTE *)intlibname, 0L)) == NULL) { @@ -260,6 +284,7 @@ mch_init() mch_errmsg("!?\n"); mch_exit(3); } +#endif } #include @@ -284,7 +309,7 @@ mch_check_win(argc, argv) { int i; BPTR nilfh, fh; - char_u buf1[20]; + char_u buf1[24]; char_u buf2[BUF2SIZE]; static char_u *(constrings[3]) = {(char_u *)"con:0/0/662/210/", (char_u *)"con:0/0/640/200/", @@ -295,35 +320,39 @@ mch_check_win(argc, argv) char *av; char_u *device = NULL; int exitval = 4; +#ifndef __amigaos4__ struct Library *DosBase; +#endif int usewin = FALSE; /* * check if we are running under DOS 2.0x or higher */ +#ifndef __amigaos4__ DosBase = OpenLibrary(DOS_LIBRARY, 37L); if (DosBase != NULL) /* if (((struct Library *)DOSBase)->lib_Version >= 37) */ { CloseLibrary(DosBase); -#ifdef FEAT_ARP +# ifdef FEAT_ARP dos2 = TRUE; -#endif +# endif } else /* without arp functions we NEED 2.0 */ { -#ifndef FEAT_ARP +# ifndef FEAT_ARP mch_errmsg(_("Need Amigados version 2.04 or later\n")); exit(3); -#else +# else /* need arp functions for dos 1.x */ if (!(ArpBase = (struct ArpBase *) OpenLibrary((UBYTE *)ArpName, ArpVersion))) { fprintf(stderr, _("Need %s version %ld\n"), ArpName, ArpVersion); exit(3); } -#endif +# endif } +#endif /* __amigaos4__ */ /* * scan argv[] for the "-f" and "-d" arguments @@ -398,8 +427,15 @@ mch_check_win(argc, argv) /* * Make a unique name for the temp file (which we will not delete!). * Use a pointer on the stack (nobody else will be using it). + * Under AmigaOS4, this assumption might change in the future, so + * we use a pointer to the current task instead. This should be a + * shared structure and thus globally unique. */ +#ifdef __amigaos4__ + sprintf((char *)buf1, "t:nc%p", FindTask(0)); +#else sprintf((char *)buf1, "t:nc%ld", (long)buf1); +#endif if ((fh = Open((UBYTE *)buf1, (long)MODE_NEWFILE)) == (BPTR)NULL) { mch_errmsg(_("Cannot create ")); @@ -513,7 +549,8 @@ mch_input_isatty() /* * fname_case(): Set the case of the file name, if it already exists. - * This will cause the file name to remain exactly the same. + * This will cause the file name to remain exactly the same + * if the file system ignores, but preserves case. */ /*ARGSUSED*/ void @@ -528,9 +565,14 @@ fname_case(name, len) if (fib != NULL) { flen = STRLEN(name); + /* TODO: Check if this fix applies to AmigaOS < 4 too.*/ +#ifdef __amigaos4__ + if (fib->fib_DirEntryType == ST_ROOT) + strcat(fib->fib_FileName, ":"); +#endif if (flen == strlen(fib->fib_FileName)) /* safety check */ mch_memmove(name, fib->fib_FileName, flen); - vim_free(fib); + free_fib(fib); } } @@ -548,13 +590,17 @@ get_fib(fname) if (fname == NULL) /* safety check */ return NULL; - fib = (struct FileInfoBlock *)malloc(sizeof(struct FileInfoBlock)); +#ifdef __amigaos4__ + fib = AllocDosObject(DOS_FIB,0); +#else + fib = (struct FileInfoBlock *)alloc(sizeof(struct FileInfoBlock)); +#endif if (fib != NULL) { flock = Lock((UBYTE *)fname, (long)ACCESS_READ); if (flock == (BPTR)NULL || !Examine(flock, fib)) { - vim_free(fib); /* in case of an error the memory is freed here */ + free_fib(fib); /* in case of an error the memory is freed here */ fib = NULL; } if (flock) @@ -613,6 +659,7 @@ mch_get_user_name(s, len) char_u *s; int len; { + /* TODO: Implement this. */ *s = NUL; return FAIL; } @@ -625,7 +672,11 @@ mch_get_host_name(s, len) char_u *s; int len; { +#if defined(__amigaos4__) && defined(__CLIB2__) + gethostname(s, len); +#else vim_strncpy(s, "Amiga", len - 1); +#endif } /* @@ -634,7 +685,14 @@ mch_get_host_name(s, len) long mch_get_pid() { +#ifdef __amigaos4__ + /* This is as close to a pid as we can come. We could use CLI numbers also, + * but then we would have two different types of process identifiers. + */ + return((long)FindTask(0)); +#else return (long)0; +#endif } /* @@ -746,7 +804,7 @@ mch_getperm(name) if (fib != NULL) { retval = fib->fib_Protection; - vim_free(fib); + free_fib(fib); } return retval; } @@ -790,8 +848,12 @@ mch_isdir(name) fib = get_fib(name); if (fib != NULL) { +#ifdef __amigaos4__ + retval = (FIB_IS_DRAWER(fib)) ? TRUE : FALSE; +#else retval = ((fib->fib_DirEntryType >= 0) ? TRUE : FALSE); - vim_free(fib); +#endif + free_fib(fib); } return retval; } @@ -912,7 +974,7 @@ mch_exit(r) mch_settmode(tmode) int tmode; { -#ifdef __AROS__ +#if defined(__AROS__) || defined(__amigaos4__) if (!SetMode(raw_in, tmode == TMODE_RAW ? 1 : 0)) #else if (dos_packet(MP(raw_in), (long)ACTION_SCREEN_MODE, @@ -954,14 +1016,21 @@ mch_screenmode(arg) mch_get_shellsize() { struct ConUnit *conUnit; +#ifndef __amigaos4__ char id_a[sizeof(struct InfoData) + 3]; - struct InfoData *id; +#endif + struct InfoData *id=0; if (!term_console) /* not an amiga window */ - return FAIL; + goto out; /* insure longword alignment */ +#ifdef __amigaos4__ + if(!(id = AllocDosObject(DOS_INFODATA, 0))) + goto out; +#else id = (struct InfoData *)(((long)id_a + 3L) & ~3L); +#endif /* * Should make console aware of real window size, not the one we set. @@ -983,7 +1052,7 @@ mch_get_shellsize() /* it's not an amiga window, maybe aux device */ /* terminal type should be set */ term_console = FALSE; - return FAIL; + goto out; } if (oldwindowtitle == NULL) oldwindowtitle = (char_u *)wb_window->Title; @@ -1006,6 +1075,12 @@ mch_get_shellsize() } return OK; +out: +#ifdef __amigaos4__ + FreeDosObject(DOS_INFODATA, id); /* Safe to pass NULL */ +#endif + + return FAIL; } /* @@ -1046,7 +1121,7 @@ out_num(n) OUT_STR_NF(tltoa((unsigned long)n)); } -#if !defined(AZTEC_C) && !defined(__AROS__) +#if !defined(AZTEC_C) && !defined(__AROS__) && !defined(__amigaos4__) /* * Sendpacket.c * @@ -1371,8 +1446,12 @@ Chk_Abort(void) * Use and abuse as you please. */ -#define ANCHOR_BUF_SIZE (512) -#define ANCHOR_SIZE (sizeof(struct AnchorPath) + ANCHOR_BUF_SIZE) +#ifdef __amigaos4__ +# define ANCHOR_BUF_SIZE 1024 +#else +# define ANCHOR_BUF_SIZE (512) +# define ANCHOR_SIZE (sizeof(struct AnchorPath) + ANCHOR_BUF_SIZE) +#endif int mch_expandpath(gap, pat, flags) @@ -1385,19 +1464,32 @@ mch_expandpath(gap, pat, flags) char_u *starbuf, *sp, *dp; int start_len; int matches; +#ifdef __amigaos4__ + struct TagItem AnchorTags[] = { + {ADO_Strlen, ANCHOR_BUF_SIZE}, + {ADO_Flags, APF_DODOT|APF_DOWILD|APF_MultiAssigns}, + {TAG_DONE, 0L} + }; +#endif start_len = gap->ga_len; /* Get our AnchorBase */ +#ifdef __amigaos4__ + Anchor = AllocDosObject(DOS_ANCHORPATH, AnchorTags); +#else Anchor = (struct AnchorPath *)alloc_clear((unsigned)ANCHOR_SIZE); +#endif if (Anchor == NULL) return 0; +#ifndef __amigaos4__ Anchor->ap_Strlen = ANCHOR_BUF_SIZE; /* ap_Length not supported anymore */ -#ifdef APF_DODOT +# ifdef APF_DODOT Anchor->ap_Flags = APF_DODOT | APF_DOWILD; /* allow '.' for current dir */ -#else +# else Anchor->ap_Flags = APF_DoDot | APF_DoWild; /* allow '.' for current dir */ +# endif #endif #ifdef FEAT_ARP @@ -1432,7 +1524,11 @@ mch_expandpath(gap, pat, flags) */ while (Result == 0) { +#ifdef __amigaos4__ + addfile(gap, (char_u *)Anchor->ap_Buffer, flags); +#else addfile(gap, (char_u *)Anchor->ap_Buf, flags); +#endif #ifdef FEAT_ARP if (dos2) #endif @@ -1469,7 +1565,11 @@ mch_expandpath(gap, pat, flags) #endif Return: +#ifdef __amigaos4__ + FreeDosObject(DOS_ANCHORPATH, Anchor); +#else vim_free(Anchor); +#endif return matches; } diff --git a/src/os_amiga.h b/src/os_amiga.h index 06e4d1cb9..0395bceb6 100644 --- a/src/os_amiga.h +++ b/src/os_amiga.h @@ -17,9 +17,12 @@ #define HAVE_AVAIL_MEM #ifndef HAVE_CONFIG_H -# ifdef AZTEC_C +# if defined(AZTEC_C) || defined(__amigaos4__) # define HAVE_STAT_H # endif +# ifdef __amigaos4__ +# define HAVE_STDARG_H +# endif # define HAVE_STDLIB_H # define HAVE_STRING_H # define HAVE_FCNTL_H @@ -34,15 +37,24 @@ # define HAVE_DATE_TIME # endif -#define DFLT_ERRORFILE "AztecC.Err" -#define DFLT_RUNTIMEPATH "home:vimfiles,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,home:vimfiles/after" +#endif /* HAVE_CONFIG_H */ -#define BASENAMELEN 26 /* Amiga */ +#ifndef DFLT_ERRORFILE +# define DFLT_ERRORFILE "AztecC.Err" /* Should this change? */ +#endif -#define TEMPNAME "t:v?XXXXXX" -#define TEMPNAMELEN 12 +#ifndef DFLT_RUNTIMEPATH +# define DFLT_RUNTIMEPATH "home:vimfiles,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,home:vimfiles/after" +#endif -#endif /* HAVE_CONFIG_H */ +#ifndef BASENAMELEN +# define BASENAMELEN 26 /* Amiga */ +#endif + +#ifndef TEMPNAME +# define TEMPNAME "t:v?XXXXXX" +# define TEMPNAMELEN 12 +#endif #include #include @@ -155,9 +167,9 @@ typedef long off_t; #endif #ifdef FEAT_VIMINFO -#ifndef VIMINFO_FILE -# define VIMINFO_FILE "s:.viminfo" -#endif +# ifndef VIMINFO_FILE +# define VIMINFO_FILE "s:.viminfo" +# endif #endif /* FEAT_VIMINFO */ #ifndef EXRC_FILE diff --git a/src/pty.c b/src/pty.c index c28d78e43..8d177d7a9 100644 --- a/src/pty.c +++ b/src/pty.c @@ -51,7 +51,7 @@ # include #endif -#if HAVE_SYS_IOCTL_H +#ifdef HAVE_SYS_IOCTL_H # include #endif @@ -69,14 +69,14 @@ # endif #endif -#if HAVE_UNISTD_H +#ifdef HAVE_UNISTD_H # include #endif #if HAVE_TERMIO_H # include #else -# if HAVE_TERMIOS_H +# ifdef HAVE_TERMIOS_H # include # endif #endif diff --git a/src/version.c b/src/version.c index 4965c64c4..b59fa77b4 100644 --- a/src/version.c +++ b/src/version.c @@ -666,6 +666,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 156, /**/ 155, /**/ -- cgit v1.2.1