]> sigrok.org Git - libsigrok.git/blobdiff - src/strutil.c
pce-322a: Adding support for reading memory from PCE-322A SPL
[libsigrok.git] / src / strutil.c
index 3d7283b3e846e87338e7af9f97406dc266ccdee6..4b5b9ec7c2ebbecc8ba58d6166f8f074ccae16a0 100644 (file)
@@ -14,8 +14,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <config.h>
@@ -212,10 +211,11 @@ SR_PRIV int sr_atof_ascii(const char *str, float *ret)
 }
 
 /**
- * Convert a string representation of a numeric value to a @sr_rational. The
- * conversion is strict and will fail if the complete string does not represent
- * a valid number. The function sets errno according to the details of the
- * failure. This version ignores the locale.
+ * Convert a string representation of a numeric value to a sr_rational.
+ *
+ * The conversion is strict and will fail if the complete string does not
+ * represent a valid number. The function sets errno according to the details
+ * of the failure. This version ignores the locale.
  *
  * @param str The string representation to convert.
  * @param ret Pointer to sr_rational where the result of the conversion will be stored.
@@ -369,13 +369,13 @@ SR_API char *sr_period_string(uint64_t frequency)
        o = g_malloc0(30 + 1);
 
        if (frequency >= SR_GHZ(1))
-               r = snprintf(o, 30, "%" PRIu64 " ns", frequency / 1000000000);
+               r = snprintf(o, 30, "%lld ps", 1000000000000ull / frequency);
        else if (frequency >= SR_MHZ(1))
-               r = snprintf(o, 30, "%" PRIu64 " us", frequency / 1000000);
+               r = snprintf(o, 30, "%lld ns", 1000000000ull / frequency);
        else if (frequency >= SR_KHZ(1))
-               r = snprintf(o, 30, "%" PRIu64 " ms", frequency / 1000);
+               r = snprintf(o, 30, "%lld us", 1000000ull / frequency);
        else
-               r = snprintf(o, 30, "%" PRIu64 " s", frequency);
+               r = snprintf(o, 30, "%lld ms", 1000ull / frequency);
 
        if (r < 0) {
                /* Something went wrong... */