/* -*-c-*-
*
- * $Id: mpscan.c,v 1.2 1999/11/13 01:55:10 mdw Exp $
+ * $Id: mpscan.c,v 1.4 2004/04/08 01:36:15 mdw Exp $
*
* Sequential bit scan of multiprecision integers
*
* MA 02111-1307, USA.
*/
-/*----- Revision history --------------------------------------------------*
- *
- * $Log: mpscan.c,v $
- * Revision 1.2 1999/11/13 01:55:10 mdw
- * Fixed so that they compile. Minor interface changes.
- *
- * Revision 1.1 1999/09/03 08:41:12 mdw
- * Initial import.
- *
- */
-
/*----- Header files ------------------------------------------------------*/
#include "mpscan.h"
-/*----- Main code ---------------------------------------------------------*/
+/*----- Right-to-left scanning --------------------------------------------*/
/* --- @mpscan_initx@ --- *
*
int mpscan_bit(const mpscan *m) { return (MPSCAN_BIT(m)); }
+/*----- Left-to right-scanning --------------------------------------------*/
+
+/* --- @mpscan_rinitx@ --- *
+ *
+ * Arguments: @mpscan *m@ = pointer to bitscanner structure
+ * @const mpw *v, *vl@ = vector of words to scan
+ *
+ * Returns: ---
+ *
+ * Use: Initializes a reverse bitscanner from a low-level
+ * vector-and-length representation of an integer. Initially no
+ * bit is ready; you must call @mpscan_rstep@ before anything
+ * useful will come out.
+ */
+
+void mpscan_rinitx(mpscan *m, const mpw *v, const mpw *vl)
+{
+ MPSCAN_RINITX(m, v, vl);
+}
+
+/* --- @mpscan_rstep@ --- *
+ *
+ * Arguments: @mpscan *m@ = pointer to bitscanner
+ *
+ * Returns: Nonzero if there is another bit to read.
+ *
+ * Use: Steps on to the next bit in the integer. The macro version
+ * evaluates its argument multiple times.
+ */
+
+int mpscan_rstep(mpscan *m) { return (MPSCAN_RSTEP(m)); }
+
+/* --- @mpscan_rbit@ --- *
+ *
+ * Arguments: @const mpscan *m@ = pointer to bitscanner
+ *
+ * Returns: The value of the current bit.
+ *
+ * Use: Reads the value of the current bit looked at by a
+ * reverse bitscanner.
+ */
+
+int mpscan_rbit(const mpscan *m) { return (MPSCAN_RBIT(m)); }
+
/*----- That's all, folks -------------------------------------------------*/