=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/mark.c,v retrieving revision 1.8 retrieving revision 1.9 diff -c -r1.8 -r1.9 *** src/usr.bin/less/mark.c 2014/04/25 13:38:21 1.8 --- src/usr.bin/less/mark.c 2015/11/05 22:08:44 1.9 *************** *** 6,13 **** * * For more information, see the README file. */ - #include "less.h" extern IFILE curr_ifile; --- 6,16 ---- * * For more information, see the README file. */ + /* + * Modified for use with illumos. + * Copyright 2014 Garrett D'Amore + */ #include "less.h" extern IFILE curr_ifile; *************** *** 34,54 **** /* * Initialize the mark table to show no marks are set. */ ! public void ! init_mark() { int i; for (i = 0; i < NMARKS; i++) ! marks[i].m_scrpos.pos = NULL_POSITION; } /* * See if a mark letter is valid (between a and z). */ ! static struct mark * ! getumark(c) ! int c; { if (c >= 'a' && c <= 'z') return (&marks[c-'a']); --- 37,56 ---- /* * Initialize the mark table to show no marks are set. */ ! void ! init_mark(void) { int i; for (i = 0; i < NMARKS; i++) ! marks[i].m_scrpos.pos = -1; } /* * See if a mark letter is valid (between a and z). */ ! static struct mark * ! getumark(int c) { if (c >= 'a' && c <= 'z') return (&marks[c-'a']); *************** *** 65,79 **** * The mark struct may come either from the mark table * or may be constructed on the fly for certain characters like ^, $. */ ! static struct mark * ! getmark(c) ! int c; { register struct mark *m; static struct mark sm; ! switch (c) ! { case '^': /* * Beginning of the current file. --- 67,79 ---- * The mark struct may come either from the mark table * or may be constructed on the fly for certain characters like ^, $. */ ! static struct mark * ! getmark(int c) { register struct mark *m; static struct mark sm; ! switch (c) { case '^': /* * Beginning of the current file. *************** *** 87,94 **** /* * End of the current file. */ ! if (ch_end_seek()) ! { error("Cannot seek to end of file", NULL_PARG); return (NULL); } --- 87,93 ---- /* * End of the current file. */ ! if (ch_end_seek()) { error("Cannot seek to end of file", NULL_PARG); return (NULL); } *************** *** 118,125 **** m = getumark(c); if (m == NULL) break; ! if (m->m_scrpos.pos == NULL_POSITION) ! { error("Mark not set", NULL_PARG); return (NULL); } --- 117,123 ---- m = getumark(c); if (m == NULL) break; ! if (m->m_scrpos.pos == -1) { error("Mark not set", NULL_PARG); return (NULL); } *************** *** 128,151 **** return (m); } - #if PIPEC /* * Is a mark letter is invalid? */ ! public int ! badmark(c) ! int c; { return (getmark(c) == NULL); } - #endif /* PIPEC */ /* * Set a user-defined mark. */ ! public void ! setmark(c) ! int c; { register struct mark *m; struct scrpos scrpos; --- 126,145 ---- return (m); } /* * Is a mark letter is invalid? */ ! int ! badmark(int c) { return (getmark(c) == NULL); } /* * Set a user-defined mark. */ ! void ! setmark(int c) { register struct mark *m; struct scrpos scrpos; *************** *** 161,175 **** /* * Set lmark (the mark named by the apostrophe). */ ! public void ! lastmark() { struct scrpos scrpos; if (ch_getflags() & CH_HELPFILE) return; get_scrpos(&scrpos); ! if (scrpos.pos == NULL_POSITION) return; marks[LASTMARK].m_scrpos = scrpos; marks[LASTMARK].m_ifile = curr_ifile; --- 155,169 ---- /* * Set lmark (the mark named by the apostrophe). */ ! void ! lastmark(void) { struct scrpos scrpos; if (ch_getflags() & CH_HELPFILE) return; get_scrpos(&scrpos); ! if (scrpos.pos == -1) return; marks[LASTMARK].m_scrpos = scrpos; marks[LASTMARK].m_ifile = curr_ifile; *************** *** 178,188 **** /* * Go to a mark. */ ! public void ! gomark(c) ! int c; { ! register struct mark *m; struct scrpos scrpos; m = getmark(c); --- 172,181 ---- /* * Go to a mark. */ ! void ! gomark(int c) { ! struct mark *m; struct scrpos scrpos; m = getmark(c); *************** *** 190,201 **** return; /* ! * If we're trying to go to the lastmark and * it has not been set to anything yet, * set it to the beginning of the current file. */ ! if (m == &marks[LASTMARK] && m->m_scrpos.pos == NULL_POSITION) ! { m->m_ifile = curr_ifile; m->m_scrpos.pos = ch_zero(); m->m_scrpos.ln = jump_sline; --- 183,193 ---- return; /* ! * If we're trying to go to the lastmark and * it has not been set to anything yet, * set it to the beginning of the current file. */ ! if (m == &marks[LASTMARK] && m->m_scrpos.pos == -1) { m->m_ifile = curr_ifile; m->m_scrpos.pos = ch_zero(); m->m_scrpos.ln = jump_sline; *************** *** 207,214 **** * (We save the screen position even if we're not using lmark.) */ scrpos = m->m_scrpos; ! if (m->m_ifile != curr_ifile) ! { /* * Not in the current file; edit the correct file. */ --- 199,205 ---- * (We save the screen position even if we're not using lmark.) */ scrpos = m->m_scrpos; ! if (m->m_ifile != curr_ifile) { /* * Not in the current file; edit the correct file. */ *************** *** 219,261 **** jump_loc(scrpos.pos, scrpos.ln); } - #if PIPEC /* * Return the position associated with a given mark letter. * ! * We don't return which screen line the position * is associated with, but this doesn't matter much, * because it's always the first non-blank line on the screen. */ ! public POSITION ! markpos(c) ! int c; { ! register struct mark *m; m = getmark(c); if (m == NULL) ! return (NULL_POSITION); ! if (m->m_ifile != curr_ifile) ! { error("Mark not in current file", NULL_PARG); ! return (NULL_POSITION); } return (m->m_scrpos.pos); } - #endif /* PIPEC */ /* * Clear the marks associated with a specified ifile. */ ! public void ! unmark(ifile) ! IFILE ifile; { int i; for (i = 0; i < NMARKS; i++) if (marks[i].m_ifile == ifile) ! marks[i].m_scrpos.pos = NULL_POSITION; } --- 210,247 ---- jump_loc(scrpos.pos, scrpos.ln); } /* * Return the position associated with a given mark letter. * ! * We don't return which screen line the position * is associated with, but this doesn't matter much, * because it's always the first non-blank line on the screen. */ ! off_t ! markpos(int c) { ! struct mark *m; m = getmark(c); if (m == NULL) ! return (-1); ! if (m->m_ifile != curr_ifile) { error("Mark not in current file", NULL_PARG); ! return (-1); } return (m->m_scrpos.pos); } /* * Clear the marks associated with a specified ifile. */ ! void ! unmark(IFILE ifile) { int i; for (i = 0; i < NMARKS; i++) if (marks[i].m_ifile == ifile) ! marks[i].m_scrpos.pos = -1; }